Find the answer to your Linux question:
Page 2 of 2 FirstFirst 1 2
Results 11 to 16 of 16
Unsetting functions works for me in bash. Maybe ash wants something else? I can't think of any real good way to check the current shell either, though. Maybe the best ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #11
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578

    Unsetting functions works for me in bash. Maybe ash wants something else?

    I can't think of any real good way to check the current shell either, though. Maybe the best way is this:
    Code:
    SHELL=$(basename ${0#-})

  2. #12
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    Yes, I can unset functions in bash. In ash, it seems like it works since it gives no errors but when I use the command set, I see that the underscore variable is set to whatever function I last created.

    I'm glad you brought up the curly brace notation. The book that I'm reading states that anything in regular curly brace is executed in it's own sub shell as opposed to the curly bracket, which is executed in the current shell. Is this correct?
    The best things in life are free.

  3. #13
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    I'm not sure about the "curly" notations. I use "parentheses" for (), "brackets" for [] and "braces" for {}. I don't know if that's right, though. What are the curly notations?

  4. #14
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    brace = ()
    square brace = []
    curly brace = {}

    That's how I learned it at school but it's really not that important how we distinguish the difference as long as both parties know which one they are referring to.
    Anyhow, back to the example (using the notation I just used), I read that anything inside a () is executed in a subshell as opposed to a curly brace which is executed in the current shell. How true is this? While the first theory seems to work, the second doesn't even run in sh or bash. I get syntax errors. Of course when dealing with the curly brace, I'm not referring to the builtin substitution or regexp.
    The best things in life are free.

  5. #15
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    That is perfectly true. This works for me:
    Code:
    $ (test=jpbarda)
    $ echo $test
    
    $ { test=jpbarda; }
    $ echo $test
    jpbarda
    Note, however, that you will need to have the whitespace around the {} and also the semicolon after the command for that syntax to work.

  6. #16
    Linux Engineer
    Join Date
    Nov 2002
    Location
    Queens, NY
    Posts
    1,319
    The spacing and the semi colon were the missing components. I always forget that the Bourne shell is picky about that.
    The best things in life are free.

Page 2 of 2 FirstFirst 1 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •