シェルスクリプトに関する総合スレッドです。
全般
・荒しは無視しましょう。
・丁寧な姿勢を心掛けましょう。
・ネチケット(死語)を意識しましょう。
・「○○(他の言語)でいいやん」は禁止。他のスレに行ってください。
シェルスクリプト総合 その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
■ このスレッドは過去ログ倉庫に格納されています
ニュース
- 【前橋市】小川晶前市長とラブホテルで打ち合わせをした54歳男性職員を停職処分 今月末で依願退職するという [シャチ★]
- 【おこめ券】鈴木農相 米価維持の意図「一切ない」★2 [ぐれ★]
- 【埼玉】「無免許で高速道路で事故」トラックの追突事故で10代男性死亡 無免許過失運転致死の疑いでトルコ国籍の男(22)逮捕 戸田市 [ぐれ★]
- バリ島で男子生徒ら集団万引きか、防犯カメラ映像が拡散 京都の大谷中学・高校が「窃盗行為」謝罪★6 [七波羅探題★]
- 広島・廿日市、おこめ券配布せず 全市民に3000円現金給付へ [どどん★]
- 【警視庁】走行中の電車で女性に露出した下半身押しつけたか 無職の男(46)逮捕「チャンスがあればいつでもやる」 [nita★]
- 結局、おこめ券と高市とのおめこ券ならどっち選ぶんだよ [784715804]
- 【実況】博衣こよりのえちえちチーズケーキを仕込み(雑談あり)🧪★2
- じゃあ何券だったら、日本人は満足したんだよ [452836546]
- 【速報】1ポンド210円で日英GDP逆転(残り1.5円)...世界6位の経済規模に転落 [237216734]
- 朝日新聞記者「中国軍のレーダー照射はこめかみに銃を突きつけられたのと同じ。僕なら反撃して撃墜してる」高市 [931948549]
- 野党が“おこめ券”追及 高市早苗「鈴木農水大臣がお米券大好きなんよ」😹 [817148728]
