Unterhaltung
Nachrichten
-
mkdir -p /tmp/ask; cd /tmp/ask && touch -- -i askme && rm *
- mcscx und clacke gefällt das.
-
@drak Nice one :-) A reminder to prefer ./* to *.
drak gefällt das. -
drak gefällt das.
-
@benediktg don't try this (unless you want to delete your home dir): "touch -- -rf \$HOME askme; rm *" @drak #DONTTRYTHISATHOME
drak gefällt das. -
@benediktg oh, interesting, why is your "-i" file still there? Doesnt zsh expand "*" to "-i askme"?
-
yes, it does. And then rm does `rm -i askme`, meaning: delete askme with required user interaction (-i) :)
mcscx gefällt das. -
did you try this? It does not work for me.
-
@drak indeed it doesnt work. It seems bash doesn't do variable expansion after pathname expansion.I wonder if there are other malicious ways
drak gefällt das. -
!bash tip: After setting "shopt -s extglob" you can exclude patterns from bash's #pathname #expansion:
ls /bin/!(*a*|*b*)drak gefällt das. -
@mcscx Ooh, yes, nice workaround.
Or just, in scripts always put filenames after `--` when possible. It's hard enough to quote everything everywhere. -
@mcscx Nope, the evaluation order of the various replacements in bash is pretty clearly documented, and I'm sure it's in one of @perloid's excellent episodes. :-)
drak gefällt das.