-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsurround
More file actions
executable file
·41 lines (39 loc) · 786 Bytes
/
Copy pathsurround
File metadata and controls
executable file
·41 lines (39 loc) · 786 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env sh
# Surrounds the input with matching characters
if test -z $1; then
echo "ERROR: requires argument 1 to be surround character" >&2
exit 1
elif [ $1 = "{" ]; then
echo "{$(cat)}"
exit 0
elif [ $1 = "<" ]; then
echo "<$(cat)>"
exit 0
elif [ $1 = "[" ]; then
echo "[$(cat)]"
exit 0
elif [ $1 = "(" ]; then
echo "($(cat))"
exit 0
elif [ $1 = "\"" ]; then
echo "\"$(cat)\""
exit 0
elif [ $1 = "'" ]; then
echo "'$(cat)'"
exit 0
elif [ $1 = "*" ]; then
echo "*$(cat)*"
exit 0
elif [ $1 = "**" ]; then
echo "**$(cat)**"
exit 0
elif [ $1 = "_" ]; then
echo "_$(cat)_"
exit 0
elif [ $1 = "\`" ]; then
echo "\`$(cat)\`"
exit 0
else
echo "Unknown surround character" >&2
exit 1
fi