News for hackers. Stuff that matters.
Re:Escaping strings in Bash using !:q by kps on Friday October 02, 2020 @11:07PM (#24669168)
Yes,

    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.)

There are no comments on this comment yet.