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

Re: Umount completion fails when mount point or dev node contains spaces



On Mon, Jan 31, 2005 at 05:05:06PM -0800, Philippe Troin wrote:
[...]
>   # umount /mnt/mount\\040point\[\\134
> 
> The enclosed patch takes care of the problem by unescaping octal
> sequences.
> 
[...]
> +  dev_tmp=(${dev_tmp//(#b)(\\([0-7]##|\\))/$(print $match[1])})

Note that this would fail for foo\012bar

for ((i = 1; i <= $#dev_tmp; i++)); do
  eval "dev_tmp[i]=\$'${dev_tmp[i]}'"
done

should work and avoid the forks for $(print ...)

$ sudo mkdir '/mnt/f\n\1oo
quote> bar'
~$ sudo mount --bind /tmp $_
~$ tail -1 /etc/mtab
/tmp /mnt/f\134n\1341oo\012bar none rw,bind 0 0
~$ dev_tmp=('/mnt/f\134n\1341oo\012bar')
~$ print -rl -- ${dev_tmp//(#b)(\\([0-7]##|\\))/$(print $match[1])}
/mnt/f\n\1oobar

~$ dev_tmp=('/mnt/f\134n\1341oo\012bar')
~$ for ((i = 1; i <= $#dev_tmp; i++)); do
for>   eval "dev_tmp[i]=\$'${dev_tmp[i]}'"
for> done
~$ print -rl "${(@)dev_tmp}"
/mnt/f\n\1oo
bar

-- 
Stéphane



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