Groups | Search | Server Info | Login | Register


Groups > comp.unix.misc > #58

Re: unset, set variables, and arithmetic and other options

From Ivan Shmakov <oneingray@gmail.com>
Newsgroups comp.unix.shell, comp.unix.misc
Subject Re: unset, set variables, and arithmetic and other options
Date 2012-02-26 14:55 +0700
Organization Aioe.org NNTP Server
Message-ID <867gzavxk7.fsf@gray.siamics.net> (permalink)
References <9c4aeca1-4e97-49a8-87a1-c71ffc6ec33d@w4g2000vbc.googlegroups.com>

Cross-posted to 2 groups.

Show all headers | View raw


>>>>> Beta What <lite.on.beta@gmail.com> writes:

	[Cross-posting to news:comp.unix.shell, for obvious reasons.]

 > Does the shell (bash and csh) treat set variable that are set to
 > empty string "" same as unset variables.  I believe csh requires
 > variable to be set.  For bash, are unset and "" the same in all
 > contexts?  If not can you point me to when they are not?

	Consider, e. g.:

$ (a=value ; printf %s\\n "${a:-default}" "${a-default}") 
value
value
$ (a=      ; printf %s\\n "${a:-default}" "${a-default}") 
default

$ (unset a ; printf %s\\n "${a:-default}" "${a-default}") 
default
default
$ 

 > How about unset variable in operations, like arithmetic or tests?
 > From some tests it seems like bash treats unset variables as =0.

-- 
FSF associate member #7257

Back to comp.unix.misc | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

unset, set variables, and arithmetic and other options Beta What <lite.on.beta@gmail.com> - 2012-02-25 22:46 -0800
  Re: unset, set variables, and arithmetic and other options Ivan Shmakov <oneingray@gmail.com> - 2012-02-26 14:55 +0700
    Re: unset, set variables, and arithmetic and other options Beta What <lite.on.beta@gmail.com> - 2012-02-26 00:18 -0800
      Re: unset, set variables, and arithmetic and other options Janis Papanagnou <janis_papanagnou@hotmail.com> - 2012-02-26 10:59 +0100
        Re: unset, set variables, and arithmetic and other options Geoff Clare <geoff@clare.See-My-Signature.invalid> - 2012-02-27 13:14 +0000
          Re: unset, set variables, and arithmetic and other options Kaz Kylheku <kaz@kylheku.com> - 2012-02-27 13:42 +0000
  Re: unset, set variables, and arithmetic and other options John McCue <jmccue@jmclin0.hsd1.ma.comcast.net> - 2012-02-26 16:20 +0000

csiph-web