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

Re: setopt and alias questions



On Feb 8,  2:59pm, Sweth Chandramouli wrote:
} Subject: Re: setopt and alias questions
}
} On Mon, Feb 08, 1999 at 11:44:03AM -0800, Bart Schaefer wrote:
} > On Feb 8,  2:15pm, Sweth Chandramouli wrote:
} > } 
} > } for DIRNAME in ${fpath} ; do
} > }    if [[ -x ${DIRNAME}/*(.x:t) ]] ; then
} > }       autoload ${DIRNAME}/*(.x:t)
} > }    fi;
} > } done;
} > 
} > That loop will never autoload anything -- unless there happens to be a
} > file in the current directory with the same name as one in ${DIRNAME}.
} > Do you see why?
} 	yes--because i need to start cut&pasting my functions rather
} than typing them in.  that should be -n, not -x.

That won't work either (and my remark about "unless there happens to be a
file in the current directory" is wrong as well).  Filename generation is
not applied to the strings inside the [[ ... ]].  Try running this:

	function fx() {
	    mkdir /tmp/x
	    echo "echo hello" > /tmp/x/x
	    chmod +x /tmp/x/x
	    echo /tmp/x/*(x)
	    [[ -n /tmp/x/*(x) ]] && echo Got nonzero string
	    [[ -f /tmp/x/*(x) ]] && echo Globbed a file
	    [[ -x /tmp/x/*(x) ]] && echo Globbed executable file
	    [[ -x /tmp/x/x ]] && echo Found executable file
	    rm -r /tmp/x
	    [[ -n /tmp/x/*(x) ]] && echo Still got nonzero string
	    [[ -x /tmp/x/x ]] || echo Found no executable file
	}

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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