Script to set parent environment
David James Keegel
djk at munnari.oz
Sun Jan 22 23:11:03 AEST 1989
in article <186 at v7fs1.UUCP>, mvp at v7fs1.UUCP (arf) says:
]
] Some time ago I asked about how a csh script could change
] global environment variables. Thanks to everyone who responded.
] ...
] [Chris Torek's suggestion] works
] fine, but doesn't work for the specific problem I was trying to
] solve -- a script which saves its argument list, and if called
] with no arguments, uses the old argument list. (Perhaps I
] should have specified what I was trying to do more exactly.)
Yes, you should. A general solution for this is hard, a specific one
is reasonably easy.
] The way I finally kludged it was more along the lines of
]
] if $#argv > 0 then
] echo $* >~/.last-parms
] endif
] program-call `cat ~/.last-parms`
I deduce from this that you are using C-shell.
Well, my .cshrc contains the following:
alias to 'set to=\!^; \to' \!^ "'\!:2*'"
alias ot '\to "$to"' "'\!*'"
There is a horrible confusion of quotes and backslashes here, but the point
is that when I run `to' (usage: "to user message ..."; like "echo message |
write user"), it saves the user name in the variable $to, and I can use
"ot" to recover it. So these are equivalent:
% to fred hi there % to fred hi there
% to fred how are you % ot how are you
If you don't like the waste of file space from the shell script and
~/.last-parms, and you can be bothered, you feel free to adapt this idea.
--
David Keegel (djk at munnari.oz)
"Flattery will get you nowhere, unless someone else does it to you"
More information about the Comp.unix.wizards
mailing list