Code: Select all
guest@porteus:/tmp/test$ ls -otr --quoting-style=shell ./*sh
-rw-r--r-- 1 guest 0 2022-11-22 22:16 './a and b.sh'
-rwxr-xr-x 1 guest 15 2022-11-22 22:23 './c & d.sh'
guest@porteus:/tmp/test$ './c & d.sh'
./c & d.sh-test
Indeed that works.
And I use "./" as starting point of my search to have that included into the result because I need it or else would get just this:
Code: Select all
guest@porteus:/tmp/test$ 'c & d.sh'
bash: c & d.sh: command not found
because some random PATH where some video or sound files containing folders lie that I processed via my make-ffplay-script would hardly ever be in my $PATH for the shell.
ncmprhnsbl wrote: ↑22 Nov 2022, 22:37
interestingly, in arch, ls defaults to outputting quoted split named entries, where in slackware, it doesn't..
Can you please post arch's $LS_OPTIONS?
And its $QUOTING_STYLE when it exists?
Porteus' $LS_OPTIONS are:
Code: Select all
guest@porteus:/tmp/test$ echo $LS_OPTIONS
-F -b -T 0 --color=auto
man ls says
Code: Select all
--quoting-style=WORD
use quoting style WORD for entry names: literal, locale, shell,
shell-always, shell-escape, shell-escape-always, c, escape
(overrides QUOTING_STYLE environment variable)
but at least in Port there is no $QUOTING_STYLE:
Code: Select all
guest@porteus:/tmp/test$ echo $QUOTING_STYLE
guest@porteus:/tmp/test$
Added in 8 minutes 51 seconds:
At least in Slackware (Porteus) having QUOTING_STYLE as extra environment variable doesn't work:
Code: Select all
guest@porteus:/tmp/test$ QUOTING_STYLE=shell
guest@porteus:/tmp/test$ ls -otr ./*sh
-rw-r--r-- 1 guest 0 2022-11-22 22:16 ./a\ and\ b.sh
-rwxr-xr-x 1 guest 15 2022-11-22 22:23 ./c\ &\ d.sh
guest@porteus:/tmp/test$ echo $QUOTING_STYLE
shell
guest@porteus:/tmp/test$ unset QUOTING_STYLE
but adding QUOTING_STYLE=shell to the LS_OPTIONS environment variable works:
Code: Select all
guest@porteus:/tmp/test$ LS_OPTIONS='-F -b -T 0 --color=auto QUOTING_STYLE=shell'
guest@porteus:/tmp/test$ ls
a\ and\ b.sh c\ &\ d.sh
guest@porteus:/tmp/test$ ls -otr ./*sh
-rw-r--r-- 1 guest 0 2022-11-22 22:16 ./a\ and\ b.sh
-rwxr-xr-x 1 guest 15 2022-11-22 22:23 ./c\ &\ d.sh
guest@porteus:/tmp/test$ echo $LS_OPTIONS
-F -b -T 0 --color=auto QUOTING_STYLE=shell
guest@porteus:/tmp/test$
I presume one would have to export the new LS_OPTIONS globally (e.c. via rc.local at startup) to have it globally available.
Still when putting it into a script and therefore relying on its existence is risky, then I would prefer using your manual approach of
Code: Select all
/bin/ls -otr --quoting-style=shell "$@"