2 # Copyright (C) 2014 Ian Kelling
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # some basic sanity / verification
20 # I don't recommend actually running this unless you have a reason to,
21 # since it creates & deletes files, and being a test, it is not as thoroughly
24 # assumes we have trash-put in path, and that lnf-function is in .. to this files location
27 # 2 arguments, test that a file in the link location is removed and replaed with a link
34 # 2 arguments, test that directory in link location is removed and replaced with a link
41 # single argument, test that an existing non-empty directory is removed and replaced by a link
49 # 4 arguments, 2 of the link locations already contain files.
50 # test that they got removed and replaced by links
56 [[ -L a
/b
&& -L a
/c
&& -L a
/d
]]
59 # 2 arguments, test that link is made correctly
80 PATH
="$(readlink -f ${0%/*}/..):$PATH"
82 # might want to undo this if things go wrong
85 # trap errors, and output a simple bash stack trace
87 trap 'echo "${BASH_COMMAND:+BASH_COMMAND=\"$BASH_COMMAND\" }
88 ${FUNCNAME:+FUNCNAME=\"$FUNCNAME\" }${LINENO:+LINENO=\"$LINENO\" }\$?=$?"' ERR
92 # test again, using rm -rf in place of trash-put.
93 trash-put
() { rm -rf -- "$@"; }