Shell POSIX OpenSSL file decryption script follow-up #1
Although print_error_and_exit correctly sends output to standard error and exits with a non-zero status, print_usage_and_exit outputs to standard out.  I recommend explicitly accepting -h (as your case implies, but getopts hasn't been instructed to do), and if the user asks for help, then writing to standard out and returning success, but if the help is provided due to error, then writing to standard error and returning failure:

print_usage()
{
    echo "Usage: $0 [-o output_directory] filename_to_decrypt"
}

while getopts ":ho:" option
do
    case "${option}" in
        o)
            given_output_directory=${OPTARG}
            ;;
        h)
            print_usage
            exit 0
            ;;
        '?')
            print_usage &gt;&amp;2
            exit 1
            ;;
    esac
done

shift $((OPTIND - 1))

[ "$#" -eq 0 ] &amp;&amp;
    print_usage &amp;&amp; exit 1




While we're on error reporting, you might want to consider making the exit code be the first argument to print_error_and_exit rather than the last.  That can make the code easier to read, and it also allows you to pass multiple arguments, just like echo which it wraps:

print_error_and_exit()
{
    value=$1; shift
    echo "${bold_red}$* Exit code = $value.${nocolor}" 1&gt;&amp;2
    exit "$value"
}




It's good to see that you use tput to produce the terminal-specific escape codes (if they exist) for highlighting.  But it's probably not worth putting them into variables for a single use each.  I'd get rid of the variables and just write something like

print_error_and_exit()
{
    value=$1; shift
    exec &gt;&amp;2
    tput bold
    tput setaf 1   # red
    echo "$* Exit code = $value."
    tput sgr0
    exit "$value"
}


and (in the success branch)

else
    tput bold
    tput setaf 3   # yellow
    echo "Decryption successful."
    tput sgr0

    exit 0
fi




These tests are probably over-doing it:

[ ! -f "$1" ] &amp;&amp;
print_error_and_exit 3 "The given argument is not an existing file."

input_filename="$1"

[ ! -r "$input_filename" ] &amp;&amp;
print_error_and_exit 4 "Input file is not readable by you."


Unless there's a good reason we can't accept input from a pipe or other non-regular file, just skip the -f test: -r will fail if its argument doesn't exist.  It's also worth including the filename in the message - this is really useful when the user expands a variable into the call, and it doesn't expand to what she expects:

[ -r "$1" ] ||
    print_error_and_exit 3 "$1: not a readable file."


If you really feel you need different exit status for non-existent and existing-but-unreadable files (why?), then consider -e as an alternative to -f.



We should check whether the supplied output directory is actually a directory, before trying to use it:

[ -d "$output_directory" ] ||
    print_error_and_exit 4 "$output_directory: not a directory."
[ -w "$output_directory" ] ||
    print_error_and_exit 5 "Destination directory is not writeable by you."




A shorter way to write this:

if [ -z ${given_output_directory} ]
then
    output_directory="$input_filepath"
else
    output_directory="$given_output_directory"
fi


is to use parameter substitution with - modifier:

output_directory="${given_output_directory:-$input_filepath}"




I think a case helps with matching filename patterns here:

if [ "$filename_extracted_from_path" = "$filename_without_enc_extension" ]
then


I'd write that block as:

filename_extracted_from_path=$(basename "$input_filename")

# Strip .enc suffix from name if it has one, else add .dec suffix
case "$filename_extracted_from_path" in
    *.enc)
        output_filename="${filename_extracted_from_path%.enc}"
        ;;
    *)
        output_filename="$filename_extracted_from_path".dec
        ;;
esac
output_filename="$output_directory/$output_filename"


Note that there's no longer a need for $filename_without_enc_extension.



You definitely need to replace this -f with -e:

[ -f "$output_filename" ] &amp;&amp;
print_error_and_exit 6 "Destination file exists."