Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
sheel check fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobybatch committed Apr 7, 2023
1 parent 0bf25f9 commit ebf9742
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ansi2html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ processArg()
}

processArg #defaults
for var in "$@"; do processArg $var; done
for var in "$@"; do processArg "$var"; done
[ "$css_only" ] && [ "$body_only" ] && usage

# Mac OSX's GNU sed is installed as gsed
# Mac OS's GNU sed is installed as gsed
# use e.g. homebrew 'gnu-sed' to get it
if ! sed --version >/dev/null 2>&1; then
if gsed --version >/dev/null 2>&1; then
Expand Down
6 changes: 4 additions & 2 deletions colour-test
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

# Returns true if the the current terminal can show colours

if test -t 1; then
ncolors=$(tput colors)
if test -n "$ncolors" && test $ncolors -ge 8; then
nColors=$(tput colors)
if test -n "$nColors" && test "$nColors" -ge 8; then
exit 0
else
exit 1
Expand Down
14 changes: 7 additions & 7 deletions colours
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/bash

ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"
export COL_RESET=$ESC_SEQ"39;49;00m"
export COL_RED=$ESC_SEQ"31;01m"
export COL_GREEN=$ESC_SEQ"32;01m"
export COL_YELLOW=$ESC_SEQ"33;01m"
export COL_BLUE=$ESC_SEQ"34;01m"
export COL_MAGENTA=$ESC_SEQ"35;01m"
export COL_CYAN=$ESC_SEQ"36;01m"
2 changes: 1 addition & 1 deletion loggtee
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ LOGFILE=$1
LOGTAG=$2
LOGPORT=$3

/usr/bin/tee -a $LOGFILE | /usr/bin/logger -t$LOGTAG -p$LOGPORT
/usr/bin/tee -a "$LOGFILE" | /usr/bin/logger -t"$LOGTAG" -p"$LOGPORT"
43 changes: 28 additions & 15 deletions randpass
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/bash

NO_ARGS=0
USAGE="`basename $0` [-s] [-x]"
USAGE="$(basename "$0") [-s] [-x]"

source "$(dirname "$0")/colours"

function usage() {
echo $USAGE
Expand All @@ -15,31 +16,43 @@ EOF
exit
}


ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"
source "$(dirname "$0")"/colours

while getopts "hsx" options; do
case $options in
h) usage;;
x) xkcd=1;;
s) safe=1;;
*) echo "Unknown option";;
esac
done

if [ -z $xkcd ]; then
if [ -z $safe ]; then
pass=`</dev/urandom tr -dc 'A-Za-z0-9!@#$%&/()=' | head -c24`
pass=$(</dev/urandom tr -dc 'A-Za-z0-9!@#$%&/()=' | head -c24)
else
pass=`</dev/urandom tr -dc 'A-Za-z0-9' | head -c24`
pass=$(</dev/urandom tr -dc 'A-Za-z0-9' | head -c24)
fi
else
pass=$(cat /usr/share/dict/words |grep -v "'"|shuf -n4 | tr '[A-Z]' '[a-z]')
pass=$( \
grep -v "'" /usr/share/dict/words| \
shuf -n4 | \
sed 's/.*/\L&/g' | \
iconv -f utf8 -t ascii//TRANSLIT \
)
fi

colours="$COL_RED $COL_GREEN $COL_YELLOW $COL_BLUE"

for word in $pass; do
colour=$(echo "$colours" | awk '{print $1}')
echo -en "$colour""$word"
colours=$(echo "$colours" | awk '{$1="";print $0}')
done
echo -e "$COL_RESET"

echo "$pass" | tr -d '\n' | xsel -ib

if [ "$?" ]; then
echo "The password has been pushed to your clipboard, you can paste it where you want it"
fi
echo $pass

0 comments on commit ebf9742

Please sign in to comment.