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

Re: translate all sequences of whitespace/underscores to single dashes



In theory, if we want the same effect as the original code
(which uses 'tr -s "-"'), we need

	${x//[-_[:space:]]##/-}

so that x='a_-_z' becomes 'a-z' (not 'a---z').

BTW, the line
	mv $f $new_name 2> /dev/null
in the function clean-filename() is dangerous, because two files
$f can have the same $new_name, in which case one of them is lost
(or $new_name may already exist before the function is called).

# If http://user.it.uu.se/~embe8573/conf/.zsh/files-fs is just a
# simplified version and you already have a correct handling of
# the problem then please forget this note.



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