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

Re: help adapting bashism for zsh



On 06/10/2019 03:22 PM, Bart Schaefer wrote:
> This compatibility mode differs from setting individual options such
> as KSH_ARRAYS, but can be fairly closely duplicated by using the
> "emulate" command.  If the scripts are intended to become the bodies
> of shell functions, try adding "emulate -L sh" at the top.
> 
>> Then what to do about the non-existing expansions such
>> as ${foo^^} (uppercase) and ${foo,,} (lowercase), etc..
> These are handled with (in those specific examples) ${foo:u} and
> ${foo:l}.  In fact ^^ has a completely different meaning in zsh, so
> you will have to do a search-and-replace for those kinds of
> nonstandard tricks.

Thank you Bart,

  That seems like the logical path forward. I was sure hoping somebody already
had a handy-dandy parse & convert routine, but it looks like a normal convert
as you go. As I go through them I'll try and keep a list of the most common
bash/zsh conversions and notes of those cases where there is no 1-for-1
replacement. It will be an as-time-permits endeavour, but maybe we can catch
most issues.

-- 
David C. Rankin, J.D.,P.E.



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