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

Re: named directory expansion on strings



On Mar 13,  6:48pm, Thorsten Kampe wrote:
:
: Fortunately, I found a better way[1]. Any style comments on my first
: /really complicated/ ;-) zsh shell script welcome!

Nothing major ...

: | for file in /etc/profile.d/zshell.zsh \
: |             /etc/zsh/zprofile         \
: |             /etc/zprofile             \
: |             ~/.zsh/.zlogin            \
: |             ~/.zsh/.zshrc             \
: |             ~/.zshenv
: | do
     ...
: | done

If you want to list every name on its own line like that, you might try
the parenthesized list syntax:

    for file (
	/etc/profile.d/zshell.zsh
	/etc/zsh/zprofile
	/etc/zprofile
	~/.zsh/.zlogin
	~/.zsh/.zshrc
	~/.zshenv
      )
    do
     ...
    done

Not compatible with non-zsh shells, of course.  Also works with the
word "foreach", in which case you may omit the "do" and replace "done"
with "end" (syntax stolen from csh).

: |         print ${(r.$JUSTIFY.):-"${ltred}! ${white}..."

You don't need $JUSTIFY there: (r.JUSTIFY.) is sufficient, because the
expression is interpreted in math context where all non-keywords are
variable references.

: Long live the Zen of Python[2].

Hrm.  As far as I'm concerned, the Python folks went wrong when they gave
semantic significance to depth of whitespace indentation, and all of the
right decisions they've made since have been a waste of effort.



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