Quick question:

Anyone know if Bash has a variable to hold the command line args before they were expanded?

If I type myscript *, $@ holds the expanded list. Is there a variable that holds the '*'?

#Linux #Bash

@c64whiz

(That answer is irrelevant now, it was meant to answer the myscript \* question which turned out to be a typo)

No, that's actually not what happens: if you escape the asterisk, it is passed to the process as-is. It is just expanded when you use it.

See the difference of echo $@ vs. echo "$@"

@c64whiz And no, there is no way to get the parameter list before expansion from your sub-process. That information simply doesn't exist. When you call some command from your shell, the shell does parameter expansion and creates the commandline for the sub-process it spawns, and that can only see its commandline, not what you actually typed into your shell.

@Werschweinchen

Frick...the '\' was to get Mastodon to leave the '*' alone...not escape it out. Apparently it was not needed inside back-ticks.

I do understand the notion of expansion and escape to avoid expansion.

You're second post answers my question, "...there is no way to get the parameter list before expansion...". I didn't think so, but thought I'd ask.

(Oh, I fixed the original post with the '\'. I should have proof-read better.)