Skip to content

Commit

Permalink
Add ssam.
Browse files Browse the repository at this point in the history
  • Loading branch information
deadpixi committed Jul 7, 2020
1 parent 4d35598 commit 1dcf1de
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ install:
cd sam; $(MAKE) install
cd samterm; $(MAKE) install
cd doc; $(MAKE) install
cp ssam $(BINDIR)
chmod +x $(BINDIR)/ssam

uninstall:
@xdg-desktop-menu uninstall --mode $(MODE) deadpixi-sam.desktop || echo "unable to uninstall desktop entry"
Expand Down
64 changes: 64 additions & 0 deletions ssam
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh
arg0=`basename "$0"`

usage()
{
printf "usage: %s [-n] [-e script] [-f sfile] [file ...]\n" "$1"
}

flagn=0
flage=""
flagf=""

while getopts ne:f:h OPT; do
case "$OPT" in
n)
flagn=1
;;

e)
if [ -z "$OPTARG" ]; then
usage "$arg0"
exit 1
fi
flage="$OPTARG"
;;
f)
if [ -z "$OPTARG" ]; then
usage "$arg0"
exit 1
fi
flagf="$OPTARG"
;;
h)
usage "$arg0"
exit 0
;;
esac
done
shift `expr "$OPTIND" - 1`

if [ -z "$TMPDIR" ]; then
TMPDIR="/tmp"
fi
tmp="$TMPDIR/ssam.tmp.$USER.$$"

cat "$@" >$tmp

input()
{
# select entire file
echo ',{'
echo k
echo '}'
echo 0k

# run scripts, print
[ ! -z "$flagf" ] && cat "$flagf"
[ ! -z "$flage" ] && echo "$flage"
[ "$flagn" -eq 0 ] && echo ','
}

input | sam -d "$tmp" 2>/dev/null

rm -f "$tmp"

0 comments on commit 1dcf1de

Please sign in to comment.