開発ツール/CygwinでWindowsのパスが必要になった時の対処方法・cygpath
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* CygwinでWindowsのパスが必要になった時の対処方法・cygpat...
たとえば、Cygwinでsakuraエディタのaliasを設定しており、~
エディタで開くファイルを指定するとファイルが開けない状態...
アプリケーションによってはエラーとなります。~
これは、WindowsアプリケーションがWindows形式のパス記述を...
UNIX形式のパス記述で引数が渡されエラーとなっているためで...
本資料は、cygpathコマンドを使用し、この問題を解決します。
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* cygpathコマンドを使ってみる [#w7e3ca23]
以下のようにaliasでsakuraエディタを指定しています。
sakura@win7pc ~
$ alias sakura='/cygdrive/c/Program\ Files\ \(x86\)/saku...
sakura@win7pc ~
$ alias
alias cls='clear'
alias df='df -h'
alias du='du -h'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -l'
alias sakura='/cygdrive/c/Program\ Files\ \(x86\)/sakura...
alias vi='vim'
テキストファイルを作成し開いてみます。
sakura@win7pc ~
$ echo hello > hello.txt
sakura@win7pc ~
$ sakura hello.txt &
#ref(01.png)
#br
上記の通り、カレントディレクトリにあるファイルであれば問...
しかし以下のようにオペレーションをすると、何も表示されな...
sakura@win7pc ~
$ echo hello > /tmp/hello.txt
sakura@win7pc ~
$ sakura /tmp/hello.txt &
#ref(02.png)
#br
これは、sakuraエディタにUNIX形式のパスを与えたためだと思...
このような場合、cygpathコマンドを使ってUNIX(Cygwinが管理...
cygpathコマンドのヘルプは以下の通りです。
$ cygpath --help
Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]....
cygpath [-c HANDLE]
cygpath [-ADHOPSW]
cygpath [-F ID]
Convert Unix and Windows format paths, or output system ...
Output type options:
-d, --dos print DOS (short) form of NAMEs ...
-m, --mixed like --windows, but with regular...
-M, --mode report on mode of file (binmode ...
-u, --unix (default) print Unix form of NAM...
-w, --windows print Windows form of NAMEs (C:\...
-t, --type TYPE print TYPE form: 'dos', 'mixed',...
Path conversion options:
-a, --absolute output absolute path
-l, --long-name print Windows long form of NAMEs...
-p, --path NAME is a PATH list (i.e., '/bin...
-U, --proc-cygdrive Emit /proc/cygdrive path instead...
when converting Windows path to ...
-s, --short-name print DOS (short) form of NAMEs ...
-C, --codepage CP print DOS, Windows, or mixed pat...
codepage CP. CP can be a numeri...
or one of the reserved words ANS...
If this option is missing, cygpa...
character set defined by the cur...
System information:
-A, --allusers use `All Users' instead of curre...
-D, --desktop output `Desktop' directory and e...
-H, --homeroot output `Profiles' directory (hom...
-O, --mydocs output `My Documents' directory ...
-P, --smprograms output Start Menu `Programs' dir...
-S, --sysdir output system directory and exit
-W, --windir output `Windows' directory and e...
-F, --folder ID output special folder with numer...
Other options:
-f, --file FILE read FILE for input; use - to re...
-o, --option read options from FILE as well (...
-c, --close HANDLE close HANDLE (for use in capture...
-i, --ignore ignore missing argument
-h, --help output usage information and exit
-V, --version output version information and e...
上記のオペレーションを確認すると、-wと-pを使えば実現でき...
実際にcygpathをつかってみます。
sakura@win7pc ~
$ sakura $(cygpath -wp /tmp/hello.txt) &
#ref(03.png)
Windows形式のパスが展開され問題なく表示されているのが確認...
* cygpathの動作を見てみる [#ta6fd851]
上記でcygpathに与えた-wpオプションとパスがどのように動作...
sakura@win7pc ~
$ cygpath -wp /tmp/
D:\cygwin\cygwin64\tmp\
sakura@win7pc ~
$ cygpath -wp /opt
D:\cygwin\cygwin64\opt
sakura@win7pc ~
$ cygpath -wp /cygdrive/
D:\cygwin\cygwin64\cygdrive\
sakura@win7pc ~
$ cygpath -wp /cygdrive/c
C:\
上記のようにWindowsの絶対パスに変換されます。~
CygwinのパスがWindowsのどこになるの?と思われた場合もcygp...
例えばカレントディレクトリを調べたい場合は以下のようにな...
$ cygpath -wp $(pwd)
D:\cygwin\cygwin64\home\sakura
$ cygpath -wp `pwd`
D:\cygwin\cygwin64\home\sakura
以上、CygwinでWindowsのパスが必要になった時の対処方法でし...
#htmlinsertpcsp(win-btm.html,win-sp.html)
終了行:
#navi(../)
* CygwinでWindowsのパスが必要になった時の対処方法・cygpat...
たとえば、Cygwinでsakuraエディタのaliasを設定しており、~
エディタで開くファイルを指定するとファイルが開けない状態...
アプリケーションによってはエラーとなります。~
これは、WindowsアプリケーションがWindows形式のパス記述を...
UNIX形式のパス記述で引数が渡されエラーとなっているためで...
本資料は、cygpathコマンドを使用し、この問題を解決します。
#contents
#htmlinsertpcsp(win-top.html,win-sp.html)
* cygpathコマンドを使ってみる [#w7e3ca23]
以下のようにaliasでsakuraエディタを指定しています。
sakura@win7pc ~
$ alias sakura='/cygdrive/c/Program\ Files\ \(x86\)/saku...
sakura@win7pc ~
$ alias
alias cls='clear'
alias df='df -h'
alias du='du -h'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -l'
alias sakura='/cygdrive/c/Program\ Files\ \(x86\)/sakura...
alias vi='vim'
テキストファイルを作成し開いてみます。
sakura@win7pc ~
$ echo hello > hello.txt
sakura@win7pc ~
$ sakura hello.txt &
#ref(01.png)
#br
上記の通り、カレントディレクトリにあるファイルであれば問...
しかし以下のようにオペレーションをすると、何も表示されな...
sakura@win7pc ~
$ echo hello > /tmp/hello.txt
sakura@win7pc ~
$ sakura /tmp/hello.txt &
#ref(02.png)
#br
これは、sakuraエディタにUNIX形式のパスを与えたためだと思...
このような場合、cygpathコマンドを使ってUNIX(Cygwinが管理...
cygpathコマンドのヘルプは以下の通りです。
$ cygpath --help
Usage: cygpath (-d|-m|-u|-w|-t TYPE) [-f FILE] [OPTION]....
cygpath [-c HANDLE]
cygpath [-ADHOPSW]
cygpath [-F ID]
Convert Unix and Windows format paths, or output system ...
Output type options:
-d, --dos print DOS (short) form of NAMEs ...
-m, --mixed like --windows, but with regular...
-M, --mode report on mode of file (binmode ...
-u, --unix (default) print Unix form of NAM...
-w, --windows print Windows form of NAMEs (C:\...
-t, --type TYPE print TYPE form: 'dos', 'mixed',...
Path conversion options:
-a, --absolute output absolute path
-l, --long-name print Windows long form of NAMEs...
-p, --path NAME is a PATH list (i.e., '/bin...
-U, --proc-cygdrive Emit /proc/cygdrive path instead...
when converting Windows path to ...
-s, --short-name print DOS (short) form of NAMEs ...
-C, --codepage CP print DOS, Windows, or mixed pat...
codepage CP. CP can be a numeri...
or one of the reserved words ANS...
If this option is missing, cygpa...
character set defined by the cur...
System information:
-A, --allusers use `All Users' instead of curre...
-D, --desktop output `Desktop' directory and e...
-H, --homeroot output `Profiles' directory (hom...
-O, --mydocs output `My Documents' directory ...
-P, --smprograms output Start Menu `Programs' dir...
-S, --sysdir output system directory and exit
-W, --windir output `Windows' directory and e...
-F, --folder ID output special folder with numer...
Other options:
-f, --file FILE read FILE for input; use - to re...
-o, --option read options from FILE as well (...
-c, --close HANDLE close HANDLE (for use in capture...
-i, --ignore ignore missing argument
-h, --help output usage information and exit
-V, --version output version information and e...
上記のオペレーションを確認すると、-wと-pを使えば実現でき...
実際にcygpathをつかってみます。
sakura@win7pc ~
$ sakura $(cygpath -wp /tmp/hello.txt) &
#ref(03.png)
Windows形式のパスが展開され問題なく表示されているのが確認...
* cygpathの動作を見てみる [#ta6fd851]
上記でcygpathに与えた-wpオプションとパスがどのように動作...
sakura@win7pc ~
$ cygpath -wp /tmp/
D:\cygwin\cygwin64\tmp\
sakura@win7pc ~
$ cygpath -wp /opt
D:\cygwin\cygwin64\opt
sakura@win7pc ~
$ cygpath -wp /cygdrive/
D:\cygwin\cygwin64\cygdrive\
sakura@win7pc ~
$ cygpath -wp /cygdrive/c
C:\
上記のようにWindowsの絶対パスに変換されます。~
CygwinのパスがWindowsのどこになるの?と思われた場合もcygp...
例えばカレントディレクトリを調べたい場合は以下のようにな...
$ cygpath -wp $(pwd)
D:\cygwin\cygwin64\home\sakura
$ cygpath -wp `pwd`
D:\cygwin\cygwin64\home\sakura
以上、CygwinでWindowsのパスが必要になった時の対処方法でし...
#htmlinsertpcsp(win-btm.html,win-sp.html)
ページ名: