export PATH="/usr/bin:/bin:/usr/sbin:/sbin"
export IFS=$' \t\n'
mkdir -p ~/Applications
ls -ld ~/Applications
stat -x ~/Applications
cd ~/Applications
curl -L -O http://www.bluem.net/files/Pashua.dmg
hdiutil mount Pashua.dmg
cp -R /Volumes/Pashua ~/Applications/Pashua
hdiutil unmount /Volumes/Pashua
cd ~/Applications/Pashua/Examples
cp -p example.sh example.sh.orig # backup
# some in-place text editing commands to modify ~/Applications/Pashua/Examples/example.sh
# cf. http://bash-hackers.org/wiki/doku.php?id=howto:edit-ed
export FILE="${HOME}/Applications/Pashua/Examples/example.sh"
# replace #!/bin/sh with #!/bin/bash
/bin/ed -s "${FILE}" <<< $'1,1s|bin/sh|bin/bash|\nw'
# to set the encoding to UTF-8 we add: set -- test utf8
/bin/ed -s "${FILE}" <<< $',s|\(.*Manage encoding.*\)|set -- test utf8
/bin/ed -s "${FILE}" <<< $'/conf="/;$d\nw'
# add the following configuration
/bin/cat >> "${FILE}" <<-'EOF'
conf="
*.transparency=0.95
*.title = Login Window
*.x = 550
*.y = 300
*.autoclosetime = 300
name.type = textfield
name.label = Please enter your name:
name.width = 280
name.x = 0
name.y = 110
password.type = password
password.label = Please enter your password:
password.width = 280
password.x = 0
password.y = 45
cb.type = cancelbutton
"; # end conf
pashua_run "$conf"
#pashua_run "$conf" "utf8" # alternative to "set -- test utf8" above
if [[ ${cb} -ne 0 ]]; then echo 'Login cancelled!'; exit 1; fi
printf "%s\n" "name = ${name}"
printf "%s\n" "${name}" | ruby -n -e 'p $_.to_s'
# the following command requires #!/bin/bash
# cf. http://www.lugbz.org/pipermail/lugbz-list/2006-December/016360.html
/bin/ed -s <((printf "%s\n" "${name}")) <<< $',l'
printf "%s\n" "password = ${password}"
printf "%s\n" "cb = ${cb}"
#printf "%s\n" "${password}" | /usr/bin/sudo -S /bin/ls | /usr/bin/head -n 5
/sbin/md5 -qs "${password}"
EOF
# run the script
~/Applications/Pashua/Examples/example.sh