-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrmpq
67 lines (56 loc) · 1.3 KB
/
rmpq
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/bash
## rmpq - clear out print queue files
## Copyleft 07/24/2015 JPmicrosystems GPL
## Last Modified 07/30/2018
## If no arguments, clear all
## Disallows arguments with paths so that only
## files in the print queue can be deleted
## Ignores files that don't exist or otherwise
## can't be deleted (permissions, etc.)
function delete () {
local dtt="${delete_to_trash:-0}" ## 0 if undefined or null
hash trash-put &> /dev/null ## see if trash-put is installed
(( $? )) && dtt=0 ## if not, disable this option
if (( dtt ))
then
trash-put "$@" &> /dev/null
else
rm -f "$@"
fi
}
script_name=$(basename $0) ## path stripped name of this script
config="${HOME}/.duplexpr"
e="" ## Actually delete files
##e="echo " ## debug - just say we did - DRYRUN
## Access the duplexpr configuration file
if [[ ! -r "${config}" ]]
then
echo "${script_name} - Can't read config file ${config}"
exit 1
fi
source "${config}"
if (( $? ))
then
echo "${script_name}: Bad config file ${config}"
exit 1
fi
cd "${pq}"
if (( $? ))
then
echo "${script_name}: Can't access Print Queue [$pq]"
exit 1
fi
if (( ! $# ))
then
${e} delete "${pq}"/*
else
echo $* | grep -q '/'
if (( ! $? ))
then
echo "${script_name}: No paths allowed in file names"
exit 1
else
${e} delete "$@"
fi
fi
exit 0