-
Notifications
You must be signed in to change notification settings - Fork 12
/
arguments
executable file
·38 lines (31 loc) · 1.07 KB
/
arguments
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
#!/bin/bash
# Print all command line arguments. If used in GUI, also prints relevant
# Nautilus Scripts vars and uses zenity for output
# Use -v var1 [var2...] to inspect shell/env variables
var=0
get_var() {
{ declare -p $1 2>/dev/null || echo "declare - $1: not set" ; } |
awk '/^declare/{$1="";$2=sprintf("%-3s",substr($2,2))}1'
}
i=0
while [ $# -gt 0 ]; do
((i++))
output+="\$$i=$1\n"
((var)) && vars+="$(get_var "$1")\n"
case "$1" in -v) var=1 ;; esac
shift
done
output+="$vars"
if [[ "$TERM" == "dumb" ]] ; then
if [[ "$output" ]]; then output+="\n"; fi
output+="PWD\n$PWD\n\n"
output+="NAUTILUS_SCRIPT_CURRENT_URI\n${NAUTILUS_SCRIPT_CURRENT_URI:+$NAUTILUS_SCRIPT_CURRENT_URI\n\n}"
output+="NAUTILUS_SCRIPT_SELECTED_URIS\n${NAUTILUS_SCRIPT_SELECTED_URIS:+$NAUTILUS_SCRIPT_SELECTED_URIS\n}"
output+="NAUTILUS_SCRIPT_SELECTED_FILE_PATHS\n${NAUTILUS_SCRIPT_SELECTED_FILE_PATHS:+$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS\n}"
msg=$output
msg="${msg//&/&}"
msg="${msg//</<}"
zenity --info --no-wrap --text "$msg"
else
if [[ "$output" ]]; then printf "%b" "$output"; fi
fi