4 ms·
Can't we get rid of cat somehow?
by Tepix 6y ago
Can't we get rid of cat somehow?
- kps 6y agoYes, bashquote() { printf '%q\n' "$(</dev/stdin)"; } Bash treats the string "/dev/stdin" as magic, so that works even if /dev/stdin doesn't exist. However, bash (unlike ksh) spawns a subshell for $(</dev/stdin), so using cat is actually lighter. (Also, it's not clear to me why $(<&0) doesn't work in bash.)