2 # Copyright (C) 2016 Ian Kelling
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 local help="Usage: rmln [RM_OPTION]... FILE...
18 wrap rm, expanding symlink arguments
20 Symlink arguments are recursively expanded so the links and the targets
21 are removed. All arguments to rm work.
27 # simple but correct counting past gnu rm options
30 local helped
=false
# only print our help once
32 if [[ "${@:index:1}" == -* ]]; then
33 if [[ "${@:index:1}" == --help ]] && ! $helped; then
37 if [[ "${@:index:1}" == -- ]]; then
46 for file in "${@:index}"; do
47 [[ -L "$file" ]] && _rmln_recurse
"$file"
49 rm "$@" "${targets[@]}"
53 local x
="$( readlink "$1" )"
55 [[ -L $x ]] && _rmln_recurse
"$x"