Find the answer to your Linux question:
Results 1 to 4 of 4
Hi all, I have to port a bash script to sh. The bash use the local key word in function to restrict the visibility of variables. How can I do ...
  1. #1
    Just Joined!
    Join Date
    Oct 2007
    Posts
    2

    Porting bash to sh: how to replace local?

    Hi all,

    I have to port a bash script to sh. The bash use the local key word
    in function to restrict the visibility of variables.

    How can I do that in sh?

    Thanks a lot for any hint,

    Xavier.

  2. #2
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    AFAIK, local is unnecessary. Simply saying

    Code:
    VAR=value
    Will make the variable only accessable in the scope of the current function and shell.

  3. #3
    Linux Enthusiast likwid's Avatar
    Join Date
    Dec 2006
    Location
    MA
    Posts
    649
    Well I took a look at the man page after I said that, and there is a case where it would be necessary, but to judge that you'd need to give a bit more detail as to how the script is structured and what the variable is for.

  4. #4
    Just Joined!
    Join Date
    Oct 2007
    Posts
    2
    Thank you for answer.
    It's fixed by just removing it.

    Xavier.

Posting Permissions

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