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

Re: globbing problem



On Mar 3,  3:40pm, Christian Neukirchen wrote:
} Subject: Re: globbing problem
}
} Manfred Lotz <manfred.lotz@xxxxxxxx> writes:
} 
} > function lsd() {
} > 	if (( $# > 0 )); then
} > 	  ls -d "$*"(/)
} > 	else
} > 	  ls -d *(/)
} > 	fi
} > }
} >
} > alias lsd='noglob lsd'
} 
} You need to force globbing.  Try this:
} 
} lsd() { local -a pat; pat=(${^*:-*}'(/N)'); ls -d ${~pat} }
} 
} (How to do it without a temporary variable?)

By simply doing it without a temporary variable!

    lsd() { ls -d ${^~*:-*}(/) }

If you throw in the (N) like Christian did, "lsd notadirectory" will give
you "./" which may or may not be what you want.

If you want to be able to handle other "ls" options ("lsd -l m*") then
you'll need temporaries to capture the options and patterns separately.
But handling all the possible options of "ls" is a large task all by
itself ...



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