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

Re: spaces in filenames should be a crime.



On Mon, Mar 27, 2017 at 08:53:17PM +0200, Jesper Nygårds wrote:
> If you'd suggest a solution using 'ls' on the bash-help mailing list, you'd
> get lynched. Although I have always found the tone on that list less than
> welcoming, I've taken that recommendation to heart. What is the opinion
> here? Should 'ls' as a basis for file name generation be avoided at all
> cost? It's pretty clear that it is never a necessary tool for the job.

I wouldn't say never. There are some inventive uses in the tree.


Completion/Unix/Command/_cvs:
    if _cvs_loadstat; then
      id="$(LC_ALL=C builtin zstat -g +mtime -F '%Y/%m/%d-%T' "$cvspassfile")"
    else
      id="$(LC_ALL=C ls -l "$cvspassfile")"
    fi
    if [[ "$id" != "$_cvs_pass_id" ]]; then
      slash=/
      _cvs_roots=($_cvs_roots ${${${${(f)"$(<$cvspassfile)"}#/1 }%% *}/:2401${slash}/:/})
      _cvs_pass_id="$id"
    fi


Test/C02cond.ztst:
  else
    unmodified_ls="$(ls -lu $unmodified)"
    print -u $ZTST_fd 'This test takes up to 60 seconds...'
  fi
  sleep 2
  [...]
       { (( $+unmodified_ls )) && SECONDS=0 &&
         ! until (( SECONDS >= 58 )); do
             ZTST_hashmark; sleep 2; cat $unmodified
             [[ $unmodified_ls != "$(ls -lu $unmodified)" ]] && break
	   done }; then
    ZTST_skip="[[ -N file ]] not supported with noatime file system"


While not technically correct, I don't know if there's a better way
Completion/Zsh/Type/_file_descriptors:
	if link=$(ls -l $proc/$i); then
	  list+=( "${(r.$#fds[-1].)i} $sep ${(D)link#* -> }" )


_hg and _remote_files could probably use printf '%s\0' with some glob,
but there are systems that don't have printf (notably android which is
why _adb uses ls).



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