Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pricing on all commands by not using any at the beginning of gnu-pricing.sh #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/dirname
1 change: 1 addition & 0 deletions bin/echo
1 change: 1 addition & 0 deletions bin/pwd
1 change: 1 addition & 0 deletions bin/sed
15 changes: 9 additions & 6 deletions pricing.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/bash

#IMPORTANT: do not use any GNU tools until further notice (see below)

#get this script's directory and command name
pushd `dirname $0` > /dev/null
THISDIR=`pwd`
pushd ${0%/*} > /dev/null
THISDIR=$PWD
popd > /dev/null

#remove the pricing directory from the path
#(that way, the only commands that can't be priced are dirname, echo, and sed)
PATH=`echo $PATH | sed "s@$THISDIR:@@"`
PATH=${PATH//"$THISDIR:"/}
PATH=${PATH//":$THISDIR"/}

#IMPORTANT: GNU tools may be used after this line with no financial penalty

#set the variables needed for command and path shortcuts
THISCMD=`basename "$0"`
Expand All @@ -23,7 +27,6 @@ else
fi

#print pricing if requested
ARGS="$@"
for var in "$@"
do
if [ "$var" = "--pricing" ]
Expand Down Expand Up @@ -55,5 +58,5 @@ NEWCOUNT=$(( $USECOUNT + 1 ))
echo "$NEWCOUNT" > "$HOME/.gnu-pricing/$THISCMD.usage"

#run the command as normal
$THISCMD $ARGS
$THISCMD "$@"