add the functions needed for some keybindings
[zsh.git] / .zsh / functions / symlink_to_file
1 # -*- mode:sh -*-
2
3 local filename=${1:-""}
4
5 if [ "${#filename}" -lt 1 ]; then
6 echo "Call: $0 SYMLINK"
7 return 1
8 fi
9
10 if [ ! -L "${filename}" ]; then
11 echo "$0: ${filename} is not a symbolic link"
12 return 2
13 fi
14
15 sourcefile=$(readlink -f -n ${filename})
16 if [ ! -r "${sourcefile}" ]; then
17 echo "$0: Can't read sourcefile: $sourcefile"
18 return 3
19 fi
20
21 cp --remove-destination ${sourcefile} ${filename}