シェルスクリプトに関する総合スレッドです。
全般
・荒しは無視しましょう。
・丁寧な姿勢を心掛けましょう。
・ネチケット(死語)を意識しましょう。
・「○○(他の言語)でいいやん」は禁止。他のスレに行ってください。
シェルスクリプト総合 その32
https://mevius.5ch.net/test/read.cgi/tech/1571929725/
探検
シェルスクリプト総合 その33
■ このスレッドは過去ログ倉庫に格納されています
2020/03/23(月) 01:12:30.31ID:TYte82vJ
56デフォルトの名無しさん
2020/04/02(木) 14:38:12.64ID:BA8GpIv4 Windows 10, WSL, Ubuntu 18.04 に、Ruby のバージョンマネージャーのrbenv を、
rbenv-installer を使ってインストールしたのですが、
https://github.com/rbenv/rbenv-installer/blob/master/bin/rbenv-installer
これの34行目について、
rbenv="$(command -v rbenv ~/.rbenv/bin/rbenv | head -1)"
これを、bash スクリプト内に書いて、スクリプトを実行すると、
xxx="$(command -v rbenv)"
xxx は、~/.rbenv/bin/rbenv とパスが入り、
これを端末で直接実行すると、
xxx は、rbenv となって、パスが入らない!
bash スクリプト内に書いて、それを実行した時と、
端末に直接入力した時では、結果が異なってしまう!
rbenv-installer を使ってインストールしたのですが、
https://github.com/rbenv/rbenv-installer/blob/master/bin/rbenv-installer
これの34行目について、
rbenv="$(command -v rbenv ~/.rbenv/bin/rbenv | head -1)"
これを、bash スクリプト内に書いて、スクリプトを実行すると、
xxx="$(command -v rbenv)"
xxx は、~/.rbenv/bin/rbenv とパスが入り、
これを端末で直接実行すると、
xxx は、rbenv となって、パスが入らない!
bash スクリプト内に書いて、それを実行した時と、
端末に直接入力した時では、結果が異なってしまう!
2020/04/02(木) 14:41:15.78ID:o0fN+e0O
2020/04/02(木) 19:04:30.73ID:mH0OQczo
5956
2020/04/02(木) 21:38:05.69ID:BA8GpIv4 端末で、command -V rbenv, type rbenv を入力したら、
両方とも、rbenv という関数が表示された!
でも、 which rbenv と入力すると、
~/.rbenv/bin/rbenv と、ちゃんとパスが返ってくるけど
rbenv ()
{
local command;
command="${1:-}";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
両方とも、rbenv という関数が表示された!
でも、 which rbenv と入力すると、
~/.rbenv/bin/rbenv と、ちゃんとパスが返ってくるけど
rbenv ()
{
local command;
command="${1:-}";
if [ "$#" -gt 0 ]; then
shift;
fi;
case "$command" in
rehash | shell)
eval "$(rbenv "sh-$command" "$@")"
;;
*)
command rbenv "$command" "$@"
;;
esac
}
2020/04/02(木) 22:11:52.53ID:mH0OQczo
which -- locate a program file in the user's path
command - execute a simple command
-v
Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name
以下省略するが読め
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
command - execute a simple command
-v
Write a string to standard output that indicates the pathname or command that will be used by the shell, in the current shell execution environment (see Shell Execution Environment), to invoke command_name, but do not invoke command_name
以下省略するが読め
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 日本の立場説明へ…外務省局長が北京到着 “台湾有事”首相答弁に中国反発 ★3 [煮卵★]
- 国内ホテル、既にキャンセルも 訪日客関連業界、事態見守る ★2 [蚤の市★]
- NHK、受信料の未払い世帯に督促強化へ 民事手続きの新組織を設置 差し押さえなどの強制執行も [1ゲットロボ★]
- 【日本大使館】中国在留邦人は安全確保を [ぐれ★]
- 【外交】日中関係悪化、長期化の様相 2012年には自動車輸出80%減も ロイター★2 [1ゲットロボ★]
- 【野球】井端監督 大谷翔平、山本由伸らのWBCへの参加 「1日も早く返事ほしい」「待っててといっても、国内組が遅くなってしまう」★3 [冬月記者★]
- 【悲報】女性初の総理大臣 高市早苗氏、安倍晋三さんが積み上げてきたものを一瞬でぶっ壊してしまう😱wwwwwwwwwwwwwwwwwwwwww [871926377]
- トランプ聖帝「中国を倒すのではなく協力することでアメリカは強くなる!MAGA!」 高市どうすんのこれ… [878970802]
- 愛国者ナザレンコ「左翼は自己中な差別主義者で偽善者。日本人ファーストを叩いておいて台湾人が死んでも知らな〜いでしょ。中露の犬」 [856698234]
- 【高市悲報】お米券、予算効率が極悪!額面440円を500円で取得。1割以上手数料。これに事務費かけたらムダばかり。マイナ口座で良いだろ [219241683]
- 【悲報】有名ウヨ論客、「現実的に考えて中国と仲直りするしかなくね?」と言ったら野良ウヨから総叩きにあう [856698234]
- 【高市悲報】経団連会長、高市と面談「おい!ちゃんと中国と対話しろよ!😨」 [359965264]
