blob: ead078ffe8641ff96437969eaebfd86214e311b4 [file] [log] [blame]
Gavin Howard3b756a32018-10-12 17:40:21 -06001#! /bin/sh
2#
3# Copyright 2018 Gavin D. Howard
4#
5# Permission to use, copy, modify, and/or distribute this software for any
6# purpose with or without fee is hereby granted.
7#
8# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10# AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14# PERFORMANCE OF THIS SOFTWARE.
15#
16
17usage() {
18 printf "usage: %s bin_dir link\n" "$0" 1>&2
19 exit 1
20}
21
22test "$#" -gt 1 || usage
23
24bindir="$1"
25shift
26
27link="$1"
28shift
29
30cd "$bindir"
31
32for exe in ./*; do
33
34 if [ ! -L "$exe" ]; then
35
36 base=$(basename "$exe")
37
38 if [ "${base##*.}" != "$base" ]; then
39 base=${base%.*}
40 name=${$exe/$base/$link}
41 else
42 name="$link"
43 fi
44
45
46 ln -s "$exe" "./$name"
47
48 exit 0
49 fi
50
51done