barbara@lemmy.ml to Linux@lemmy.ml · 7 months agowhy does noone inprove bash such that you can write a normal foor loop with whitespace in file names?message-squaremessage-square41fedilinkarrow-up131arrow-down116file-text
arrow-up115arrow-down1message-squarewhy does noone inprove bash such that you can write a normal foor loop with whitespace in file names?barbara@lemmy.ml to Linux@lemmy.ml · 7 months agomessage-square41fedilinkfile-text
minus-squareLemoineFaircloughlinkfedilinkEnglisharrow-up1·7 months agoI write for loops involving white space in file names pretty frequently. For example: export LC_ALL=POSIX && unset IFS && for file in 'a file' 'another file'; do touch -- "${file}" || exit; done As for improving “the basic stuff”, the Shell Command Language is defined with https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html but it is possible to improve it, as evidenced by things such as: The text “A future version of this standard may” is present in the definition of the Shell Command Language. There is support for specifying the behavior of the command set -o pipefail. There are many other changes to the POSIX standard that clearly receive support, like those described at https://austingroupbugs.net/view.php?id=249 and others around https://austingroupbugs.net/view_all_bug_page.php
I write for loops involving white space in file names pretty frequently. For example:
export LC_ALL=POSIX && unset IFS && for file in 'a file' 'another file'; do touch -- "${file}" || exit; done
As for improving “the basic stuff”, the Shell Command Language is defined with https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html but it is possible to improve it, as evidenced by things such as:
set -o pipefail
.