Skip to content

Commit

Permalink
Add initial version of paargs
Browse files Browse the repository at this point in the history
  • Loading branch information
cheusov committed Mar 18, 2018
1 parent e4bc3d0 commit 753ac14
Show file tree
Hide file tree
Showing 7 changed files with 150 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -2,8 +2,8 @@ BIRTHDATE = 2008-01-25
PROJECTNAME = paexec

#####
SUBPRJ = paexec:tests presentation doc
SUBPRJ_DFLT?= paexec
SUBPRJ = paexec:tests paargs presentation doc
SUBPRJ_DFLT?= paexec paargs

examples = divide all_substr cc_wrapper cc_wrapper2 \
make_package toupper dirtest
Expand Down
1 change: 1 addition & 0 deletions Makefile.inc
Expand Up @@ -21,6 +21,7 @@ MKC_ERR_MSG += "ERROR: ${AWK} doesnt not support fflush() function"
.endif

INTEXTS_REPLS += awk ${PROG.${AWK}:U${AWK}}
INTEXTS_REPLS += version ${VERSION:U}

#
VERSION= 1.0.1
8 changes: 8 additions & 0 deletions paargs/Makefile
@@ -0,0 +1,8 @@
INSCRIPTS = paargs
SCRIPTS = ${INSCRIPTS}

MAN = paargs.1

CLEANFILES = paargs.1

.include <mkc.mk>
67 changes: 67 additions & 0 deletions paargs/paargs.in
@@ -0,0 +1,67 @@
#!/bin/sh

usage (){
cat 1>&2 <<'EOF'
paargs - wrapper for paexec
usage: paargs [OPTIONS]
OPTIONS:
h display this help
V display version
P
t
X
f
m
I
0
Z
z
EOF
}

command='paexec -Cxleg'
version='@version@'

shquote (){
__cmd=`printf '%s\n' "$1" | sed "s|'|'\\\\\''|g"`
printf "%s\n" "'$__cmd'"
}

while getopts 0fI:hm:P:t:VXzZ: f; do
case "$f" in
'?')
exit 1;;
h)
usage
exit 0;;
V)
echo "paargs $version written by Aleksey Cheusov"
exit 0;;
P)
command="$command -n`shquote $OPTARG`";;
t)
command="$command -t`shquote $OPTARG`";;
X)
command="$command -X";;
f)
command="$command -E";;
m)
command="$command -m`shquote $OPTARG`";;
I)
command="$command -J`shquote $OPTARG`";;
0)
command="$command -0";;
Z)
command="$command -w -Z`shquote $OPTARG`";;
z)
command="$command -w -z";;
esac
done
shift `expr $OPTIND - 1`

if test $# -eq 0; then
echo 'paargs: missing arguments. Run paargs -h for details' 1>&2
exit 1
fi

eval $command "$@"
26 changes: 26 additions & 0 deletions paargs/paargs.pod
@@ -0,0 +1,26 @@
=head1 NAME

paargs - lalala

=head1 SYNOPSIS

B<paexec> I<[options]>

B<paexec> -C I<[options]> I<command> I<[args...]>

=head1 DESCRIPTION

lalala

=head1 BUGS/FEEDBACK

Please send any comments, questions, bug reports etc. to me by e-mail
or (even better) register them at sourceforge project home. Feature
requests are also welcomed.

=head1 HOME

L<http://sourceforge.net/projects/paexec>

=head1 SEE ALSO
L<paexec(1)>
1 change: 1 addition & 0 deletions tests/Makefile
Expand Up @@ -20,6 +20,7 @@ all:
export PATH=${.CURDIR}/../examples/toupper:$$PATH; \
export PATH=${.CURDIR}/../examples/wav2flac:$$PATH; \
export PATH=${OBJDIR_paexec}:$$PATH; \
export PATH=${OBJDIR_paargs}:$$PATH; \
export PATH=${OBJDIR_scripts}:$$PATH; \
export PATH=${OBJDIR_transp_closed_stdin}:$$PATH; \
export PATH=${OBJDIR_all_substr}:$$PATH; \
Expand Down
47 changes: 45 additions & 2 deletions tests/test.sh
Expand Up @@ -20,12 +20,16 @@ runtest_resort (){
$EXEPREFIX paexec "$@" 2>&1 | resort
}

runpaargs (){
$EXEPREFIX paargs "$@" 2>&1
}

cut_version (){
awk '$1 == "paexec" {$2 = "x.y.x"} {print}'
awk '$1 == "paexec" || $1 == "paargs" {$2 = "x.y.x"} {print}'
}

cut_help (){
awk 'NR <= 3'
awk '/^OPTIONS/ {exit 0} {print}'
}

cut_full_path_closed_stdin (){
Expand Down Expand Up @@ -333,6 +337,45 @@ cmp (){
}

do_test (){
runpaargs -V | cut_version |
cmp 'paargs -V' 'paargs x.y.x written by Aleksey Cheusov
'

runpaargs -h 2>&1 | cut_help |
cmp 'paargs -h' 'paargs - wrapper for paexec
usage: paargs [OPTIONS]
'

runpaargs -t ssh -P localhost < /dev/null 2>&1 |
cmp 'paargs missing free arguments' \
'paargs: missing arguments. Run paargs -h for details
'

printf 'AAA\nBBB\nTRTRTR'\''BRBRBR\nCCC\nDDD\nEEE\nFFF\n"Y;X\nGGG\n' |
runpaargs -P +3 -I '{}' echo "xxx" '{}' 'yyy' | paexec_reorder -lgy -Ms |
cmp 'paargs -P #1.1' \
'1 xxx AAA yyy
1 success
2 xxx BBB yyy
2 success
3 xxx TRTRTR'"'"'BRBRBR yyy
3 success
4 xxx CCC yyy
4 success
5 xxx DDD yyy
5 success
6 xxx EEE yyy
6 success
7 xxx FFF yyy
7 success
8 xxx "Y;X yyy
8 success
9 xxx GGG yyy
9 success
'

############################################################
return 0;
runtest -V | cut_version |
cmp 'paexec -V' 'paexec x.y.x written by Aleksey Cheusov
'
Expand Down

0 comments on commit 753ac14

Please sign in to comment.