"env -" segfaults
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Thu Nov 12 15:33:02 UTC 2009
On Thu, Nov 12, 2009 at 04:17:08PM +0100, Bernd Petrovitsch wrote:
>On Thu, 2009-11-12 at 15:54 +0100, Bernhard Reutner-Fischer wrote:
>> On Thu, Nov 12, 2009 at 03:09:12PM +0100, Bernd Petrovitsch wrote:
>> >On Thu, 2009-11-12 at 16:57 +0300, Vladimir Dronnikov wrote:
>> >> >
>> >> > Using export -n or unset?
>> >> >
>> >>
>> >> I need command to effectively perform clearenv(), to unset all vars at
>> >> once ( that's why I tried "env -" :). Is there such in the nature?
>> >No, no one really wants to delete/unexport *all* environment variables
>> >as that includes $HOME and $PATH (to name 2 that come immediately to my
>> >mind).
>> >FWIW
>> >---- snip ----
>> >unset $(env | sed -e 's/=.*//')
>> >---- snip ----
>> >does the trick (in a bash). Similar should be doable for other shells.
>>
>> env | cut -d'=' -f1 | while read i;do unset $i;done
>In my world, the "cut" and "while" are in sub-processes of the original
right, my bad.
>shell (which is the reason for the "$(..)" construct. Backquote should
>do the trick too BTW). So more like
>---- snip ----
>for v in `export | while read i; do IFS="= " set -- $i; echo "$1"; done`; do unset "$v"; done
>---- snip ----
`env | cut -d'=' -f1 | while read i;do echo unset $i;done`
I'm unsure which one is uglier ;)
cheers,
More information about the busybox
mailing list