Linuxathome.net
https://www.linuxathome.net/forum/

Opposite of Unix 'set'
https://www.linuxathome.net/forum/viewtopic.php?f=1&t=66
Page 1 of 1

Author:  LordGemma [ Wed Aug 07, 2002 5:47 pm ]
Post subject:  Opposite of Unix 'set'

Hey guys,

In my shell, I do

$ set hello you

and hence $1=hello and $2=you

Anyone know how to remove this now?

I've had no luck using

$unset hello you

Author:  redlander [ Wed Aug 07, 2002 7:00 pm ]
Post subject: 

What shell are you using? Bash example:

[redlander@acid vcd]$ VAR1=test
[redlander@acid vcd]$ set | grep VAR1=
VAR1=test
[redlander@acid vcd]$ unset VAR1
[redlander@acid vcd]$ set | grep VAR1=
[redlander@acid vcd]$

Simple as that - or am I missing something?

Author:  LordGemma [ Wed Aug 07, 2002 11:50 pm ]
Post subject: 

Am using bash redlander.

$ set hello you
$ echo $1
hello
$ unset $1
$ echo $1
hello
$

After the unset, I want $1 to be back to the empty string. Any ideas what I'm doing wrong above.

Author:  redlander [ Thu Aug 08, 2002 8:50 am ]
Post subject: 

Oh...the set command shouldn't really be used for variable assignment. Every shell (except plain /bin/sh) passes set arguements as $1 $2 etc because they are treated as parameters for use in sourced scripts (or from the source command line). Short answer == don't set shell variables this way =)

Page 1 of 1 All times are UTC + 10 hours [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/