Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: sourcing a sh file in zsh



On Jan 16,  2:53pm, Evert Rol wrote:
} 
} How do I source a .sh file in zsh? It works fine in bash or sh, but  
} gives an error when source in zsh.

You'll probably need to do something like

  emulate sh
  source bla.sh

That leaves the problem of getting back to your original zsh settings
after the script is done.  Depending on what the script is supposed
to accomplish, you might be able to wrap that in a shell function:

  sh_source() {
    emulate -L sh
    source "$@"
  }

That won't work if the script wants to declare variables with typeset
and have them remain set after it finishes.

} $> source bla.sh
} bla.sh:1: bad math expression: operand expected at `'
} 
} where that line reads:
}    [ "$a_root" = "" ] && a_root=/some/dir

I suspect the line number reported in the error is inaccurate, as zsh
wouldn't invoke any math operations for that.



Messages sorted by: Reverse Date, Date, Thread, Author