Quantcast
Channel: What does "`_`, `-`, `--` or the empty string is used for the shell's error messages" mean? - Unix & Linux Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Stéphane Chazelas for What does "`_`, `-`, `--` or the empty string is used for the shell's error messages" mean?

$
0
0
$ find . -name accept_ra -exec sh -c 'echo 0 > "$1"' inline-sh {} \;
inline-sh: ./accept_ra: Permission denied

The error message tells you it's an inline-sh that fails to open a ./accept_ra file.

$ find . -name accept_ra -exec sh -c 'echo 0 > "$1"' _ {} \;
_: ./accept_ra: Permission denied
$ find . -name accept_ra -exec sh -c 'echo 0 > "$1"' '' {} \;
: ./accept_ra: Permission denied

Makes it less obvious and more confusing to the user what is actually failing to open that ./accept_ra.

Hence the recommendation to use a meaningful value for that first argument after sh -c 'code'. Repeating the command name is generally just fine. As in

sh -c 'code using "$@"' sh  actual arguments to the inline script

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>