* sq: Customizable squeue wrapper: introduce new defaults / default

behavior on squeue.
master
Wirawan Purwanto 7 years ago
parent 94e0aa9490
commit 28eb7a0d98
  1. 67
      slurm/sq

@ -0,0 +1,67 @@
#!/bin/bash
#
# Extended squeue wrapper
#
# Wirawan Purwanto
# Created: 20180720
shopt -s extglob
set -e
optAllUsers=0
optHasUsers=0
optHasFormat=0
optSlurmFlags=()
FORMAT_DEFAULT="%.18i %.9P %.20j %.9u %.2t %.12M %.12l %.5D %R"
function ParseArgs()
{
local i
local nopass
local args args_count arg
args=( "zeroth-arg-not-used" "$@" )
args_count=$#
for ((i = 1; i <= args_count; ++i)); do
arg="${!i}"
case "$arg" in
# This script's options
(+a)
optAllUsers=1
;;
(+*)
: # ignore
;;
(-*|*)
optSlurmFlags[ ${#optSlurmFlags[@]} ]="$arg"
case "$arg" in
(-u*|--user?(=*))
optHasUsers=1
;;
(-l|-s|--long|--steps|-o|--format?(=*))
optHasFormat=1
;;
esac
;;
esac
done
}
function do_squeue()
{
# My old default is to show jobs for me only:
if ! (( optHasUsers || optAllUsers )); then
optSlurmFlags=( "${optSlurmFlags[@]}" -u "$USER" )
fi
if ! (( optHasFormat )); then
optSlurmFlags=( "${optSlurmFlags[@]}" -o "$FORMAT_DEFAULT" )
fi
squeue "${optSlurmFlags[@]}"
}
ParseArgs "$@"
do_squeue
Loading…
Cancel
Save