Saving, Escaping, and Restoring positional parameters in a POSIX shell

http://www.seanius.net/blog/2009/03/saving-and-restoring-positional-params/ has a really good post about how “shift” loses the original command-line arguments, discusses various seemingly-obvious ways of restoring them, explores why they fail for certain types of input, and provides what seems to be a working solution:

one way you could try to store/save them would be to save the original copy of $@ and use eval set — later on to change it back to the saved variable

… but as it turns out, that doesn’t work with spaces, or quotes. Excellent, really concise description of the problem(s) and solution(s).

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: