In bash/zsh we use $_
representing the last argument to the previous command for later use, but this parameter contains the "expanded version" as documented. is there a thing that I can have un-expanded version of that? like in below example:
printf "%s\n" something{1..3}
I want to have access to un-expanded something{1..3}
argument in the later command, not only something3
.
doing this way also still adds only to very last argument not for all.
bash -c '
printf "%s\n" "$@" && printf "%s\n" "$@"-add-something-more;
' _ something{1..3}
same in zsh
, is there a way to to get that without eval
trick that I don't preferer to use this way but want to show what exactly I want to have?
bash -c '
eval printf "%s\\\n" "$@" && eval printf "%s\\\n" "$@"-add-something-more;
' _ 'something{1..3}'
something1
something2
something3
something1-add-something-more
something2-add-something-more
something3-add-something-more
Notes:
- Reading from the history is not an option as commands would executing within script and arguments would passing to the script by a user.
- I'm using
command1 "$@" && command2 "$@"<question-part>
syntax to executecommand2
only ifcommand1
was executed successfully.
zsh
:fc -n -l -1 | awk '{ print $NF }'
(not an answer as I don't explain anything or say anything aboutbash
; there are probably better ways too).insert-last-argument (M-., M-_)
but that can be used non-interactively?