This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
err_report() { | |
ERR=$? | |
echo "$1 failed on line $2 ('$3') with error code $ERR" 1>&2 | |
exit $ERR | |
} | |
trap 'err_report "$BASH_SOURCE" "$LINENO" "$BASH_COMMAND"' ERR | |
echo "l" | grep f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# source: https://wiki.archlinux.org/index.php/Color_Bash_Prompt | |
txtblk='\e[0;30m' # Black - Regular | |
txtred='\e[0;31m' # Red | |
txtgrn='\e[0;32m' # Green | |
txtylw='\e[0;33m' # Yellow | |
txtblu='\e[0;34m' # Blue | |
txtpur='\e[0;35m' # Purple | |
txtcyn='\e[0;36m' # Cyan | |
txtwht='\e[0;37m' # White |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def note_error(self, *msg): | |
if self.strict: | |
raise PermError(*msg) | |
# if lax mode, note error and continue | |
if not self.perm_error: | |
try: | |
raise PermError(*msg) | |
except PermError as x: | |
# FIXME: keep a list of errors for even friendlier diagnostics. | |
self.perm_error = x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validate_account_number(value): | |
checksum = sum(int(value[i]) * (8-i) for i in range(7)) % 11 | |
last_digit = int(value[-1]) | |
if checksum in [0, 10]: | |
c = 1 | |
elif checksum == 1: | |
c = 0 | |
else: | |
c = 11 - checksum |
OlderNewer