長くてスイッチが多いコマンドを呼び出すときは、シェルスクリプトで記述することをお勧めします。そのようなスクリプトの行にコメントを付ける簡単な方法はありますか?次の方法を試しましたが、どちらも機能しません。
# the \ is also commented out, resulting in "command" and "--good-switch".
command \
#--bad-switch \
--good-switch \
# seems to send an extra argument to the command
command \
\ #--bad-switch \
--good-switch
これはオプションの可能性があります。コマンドと引数を配列に格納し、その後で実行します。
# build the command
cmd=( ls
-F
# -a # comment out this option temporarily
-l
)
# $cmd is now an array with 3 elements
# execute it
"${cmd[@]}"
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加