Linuxathome.net

Linux news and help for home broadband internet users
It is currently Tue Jun 27, 2017 5:51 am

All times are UTC + 10 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Opposite of Unix 'set'
PostPosted: Wed Aug 07, 2002 5:47 pm 
Offline
Newbie

Joined: Sat Jul 27, 2002 6:29 pm
Posts: 7
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 07, 2002 7:00 pm 
Offline
Newbie

Joined: Sun Jun 30, 2002 10:51 am
Posts: 24
Location: /dev/null
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?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Aug 07, 2002 11:50 pm 
Offline
Newbie

Joined: Sat Jul 27, 2002 6:29 pm
Posts: 7
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.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Aug 08, 2002 8:50 am 
Offline
Newbie

Joined: Sun Jun 30, 2002 10:51 am
Posts: 24
Location: /dev/null
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 =)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 10 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group