with <t8je2e$unq$1@dont-email.me> Janis Papanagnou wrote:
On 18.06.2022 02:16, Brian Patrie wrote:
*SKIP*
So what to do then? - Something like this...?
zsh -c 'set -o nullglob ; echo W[0-5][0-9](N/^F)' | xargs -r rmdir
You can do better:
zsh -Gc 'echo W[0-5][0-9](/^F)' | xargs -r rmdir
In article <slrntarjm8.phb.whynot@orphan.zombinet>, Eric Pozharski <whynot@pozharski.name> wrote:
with <t8je2e$unq$1@dont-email.me> Janis Papanagnou wrote:
On 18.06.2022 02:16, Brian Patrie wrote:
If you're willing to go that far down the rabbit-hole, wouldn't it be
easier to just write a cuatom C program to do what you want?
In article <slrntarjm8.phb.whynot@orphan.zombinet>,
Eric Pozharski <whynot@pozharski.name> wrote:
with <t8je2e$unq$1@dont-email.me> Janis Papanagnou wrote:
On 18.06.2022 02:16, Brian Patrie wrote:
*SKIP*
So what to do then? - Something like this...?
zsh -c 'set -o nullglob ; echo W[0-5][0-9](N/^F)' | xargs -r rmdir
You can do better:
zsh -Gc 'echo W[0-5][0-9](/^F)' | xargs -r rmdir
If you're willing to go that far down the rabbit-hole, wouldn't it be
easier to just write a cuatom C program to do what you want?
On 18.06.2022 20:00, Kenny McCormack wrote:
In article <slrntarjm8.phb.whynot@orphan.zombinet>, Eric Pozharski
<whynot@pozharski.name> wrote:
with <t8je2e$unq$1@dont-email.me> Janis Papanagnou wrote:
On 18.06.2022 02:16, Brian Patrie wrote:
As I see it we have two options; use a variant of rmdir that already
supports the feature, or use the Unix tool-box to emulate it. In the
latter case there was the question whether modern globbing might
support that, and it seems zsh has a simple syntax for that. And the
xargs will do two jobs, address the exec-buffer issue and don't call
the program if no arguments are there (to prevent an error message).
One thing that is still disturbing me is how pathological filenames
will be handles by above code. Maybe we need something like
zsh -Gc 'printf "%s\0" W[0-5][0-9](/^F)' | xargs -0 -r rmdir
To compare with the other options
rmdir --ignore-fail-on-non-empty W[0-5][0-9]
find -maxdepth 1 -type d -name "W[0-5][0-9]" -empty -delete
and even the option '--ignore-fail-on-non-empty' doesn't look that
long any more.
On 20.06.2022 16:03, Eric Pozharski wrote:
May I intrigue you with simulating 'find' (zsh here, I'm pretty certain
doesn't work in bash):
slvr=( W[0-5][0-9](N/^F) )
[[ ${#slvr} ]] && rmdir $slvr
The zsh globbing would not work in ksh and probably not in bash.
But wouldn't that code (also in zsh) better be formulated as
slvr=( W[0-5][0-9](N/^F) )
[[ ${#slvr} ]] && rmdir "${slvr[@]}"
since "${slvr[@]}" is the standard to access array elements, and
filenames with spaces (etc.) would have issues (in ksh and bash).
Or is $slvr safe in that respect in zsh?
Janis
May I intrigue you with simulating 'find' (zsh here, I'm pretty certain doesn't work in bash):
slvr=( W[0-5][0-9](N/^F) )
[[ ${#slvr} ]] && rmdir $slvr
On 21.06.2022 06:52, Janis Papanagnou wrote:
On 20.06.2022 16:03, Eric Pozharski wrote:
May I intrigue you with simulating 'find' (zsh here, I'm pretty
certain doesn't work in bash):
slvr=( W[0-5][0-9](N/^F) )
[[ ${#slvr} ]] && rmdir $slvr
The zsh globbing would not work in ksh and probably not in bash.
But wouldn't that code (also in zsh) better be formulated as
slvr=( W[0-5][0-9](N/^F) )
[[ ${#slvr} ]] && rmdir "${slvr[@]}"
since "${slvr[@]}" is the standard to access array elements, and
filenames with spaces (etc.) would have issues (in ksh and bash).
Missed another thing; I'd probably write for the test one of
(( ${#slvr} )) or [[ ${#slvr} != 0 ]]
Or is $slvr safe in that respect in zsh?
with <t8rk4k$1or$1@dont-email.me> Janis Papanagnou wrote:
But wouldn't that code (also in zsh) better be formulated as
slvr=( W[0-5][0-9](N/^F) )
[[ ${#slvr} ]] && rmdir "${slvr[@]}"
since "${slvr[@]}" is the standard to access array elements, and
filenames with spaces (etc.) would have issues (in ksh and bash).
True, (abstract) you can write bash in zsh. What's (personal) your
point?
On 22.06.2022 14:50, Eric Pozharski wrote:
with <t8rk4k$1or$1@dont-email.me> Janis Papanagnou wrote:
Oh, it's just that [in ksh, bash] the $slvr in rmdir $slvr expandsTrue, (abstract) you can write bash in zsh. What's (personal) yoursince "${slvr[@]}" is the standard to access array elements, and
filenames with spaces (etc.) would have issues (in ksh and bash).
point?
to a string of elements separated also by e.g. whitespace. That's
strictly speaking not relevant in a specific case where names like W[0-5][0-9] are expanded. But in general [in ksh, bash, and I'd
suppose also in zsh] if populating an array slvr=( ... ) to keep the argument structure intact we'd better use "${slvr[@]}" to preserve the argument structure of the array elements and not get undesired word splitting. Another point is that [in ksh, bash] $slvr would not
expand the whole array but only the first element.
$ a=( "A B" "C D" )
$ printf "'%s'\n" $a
'A'
'B'
$ printf "'%s'\n" "$a"
'A B'
$ printf "'%s'\n" "${a[@]}"
'A B'
'C D'
That was my point. (And a question whether zsh behaves differently if compared to ksh, bash; as it seems to do as I've just tried.) So for
folks who are not residing solely in zsh it might be better to use the
more portable syntax that zsh also supports. For zsh-only users my
point is probably irrelevant.
*SKIP*
"${slvr[@]}"
Well, instead walls of text I would like to see references to
specifications (or something) that clearly sets order of expansions of
bash as _standard_.
Otherwise, it's just a choice that has been made
decades ago and now it's kept because backward compatibility.
Good. Now you (and hopefully others) realize there is world without
bash. My job here is done. Farewell... (and I'm doing that thing)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 307 |
Nodes: | 16 (2 / 14) |
Uptime: | 93:23:13 |
Calls: | 6,849 |
Files: | 12,352 |
Messages: | 5,414,741 |