3 usage_help_text
="Usage: qadd [<OPTIONS>] [--] [<COMMAND> <ARGS>]
4 Add new task to the end of the queue.
5 A task is a command to run with its environment.
6 Qadd tries to preserve as much from the caller's environment as it can,
7 including environment variables, exported bash functions, working directoty, umask.
20 if [ "$qadd_no_dup" -o "$qadd_no_duprun" ]
22 declare -a this_command
=("$@")
25 for itemfile
in "$queue_dir"/*.
comm
31 while read -r -d $
'\0' -u $fd arg
33 if [ $argnum -ge ${#this_command[@]} ]
38 if [ ".$arg" != ".${this_command[$argnum]}" ]
46 if [ $same_command ] && [ $argnum != ${#this_command[@]} ]
53 taskid
=`basename "$itemfile" .comm`
54 state
=`qtask_state "$taskid"`
55 if [ \
( "$qadd_no_duprun" -a "$state" = running \
) -o \
( "$qadd_no_dup" -a "$state" = queued \
) ]
57 echo "qadd: not adding, command is equivalent to task $taskid" >&2
66 last_id
=`cat "$queue_dir/.seq" 2>/dev/null || echo -n 0`
68 while [ -z "$queue_item_file" -o -e "$queue_item_file" ]
70 item_id
=$
[last_id
+ 1]
71 queue_item_file
=$queue_dir/$item_id.
comm
76 pwd > "$queue_dir/$item_id.pwd"
77 umask > "$queue_dir/$item_id.umask"
81 printf '%s\000' "$arg"
82 done > "$queue_item_file"
84 declare -p -x > "$queue_dir/$item_id.env.bash"
85 func
=`declare -p -x -f`
88 echo "$func" > "$queue_dir/$item_id.func.bash"
92 echo -n $item_id > "$queue_dir/.seq"
97 echo "qadd: task $item_id queued in $queue_dir" >&2