add unicode-aware expand command
[hband-tools.git] / queue-mgmt / qrm
blob5c65f4bf77148832cbe09c811aaa2c9720293da6
1 #!/bin/bash
3 usage_help_text="qrm [<OPTIONS>] <TASK-ID> [<TASK-ID> [...]]
4 Remove specified queued or ended task(s) from the queue.
5 May force removing gone tasks as well.
6 OPTIONS:
7 -d, --queue-dir <DIR>
8 -f, --force"
10 . qadd-common
13 shopt -s nullglob
15 if [ $# = 0 ]
16 then
17 echo "qrm: missing task id." >&2
18 exit -1
21 while [ $# -gt 0 ]
23 task_id=$1
25 if [ -z $task_id ]
26 then
27 echo "qrm: empty task ID" >&2
28 exit -3
31 if [[ $task_id =~ / ]]
32 then
33 echo "qrm: invalid task ID: $task_id" >&2
34 exit -4
37 allow_rm=yes
38 state=`qtask_state "$task_id"`
39 if [ "$state" != queued -a "$state" != ended ]
40 then
41 allow_rm=''
42 if [ "$state" = gone ]
43 then
44 if [ $force ]
45 then
46 allow_rm=yes
51 if [ ! $allow_rm ]
52 then
53 echo "qrm: task $task_id is $state. not removing." >&2
54 exit -7
57 if [ -e "$queue_dir/$task_id.comm" ]
58 then
59 rm "$queue_dir/$task_id".*
60 else
61 echo "qrm: task $task_id is not found." >&2
62 exit -5
65 shift
66 done