Locating the Bash history file for a user This looks quite verbose to me, using the command substitution and echo:

# Source file
source=$( [[ ! -z "$1" ]] &amp;&amp; echo "/home/$1" || echo '/root' )
source="$source"/.bash_history
[[ ! -f "$source" ]] &amp;&amp; echo "History file '$source' not found." 1&gt;&amp;2 &amp;&amp; exit 1;

# Am I dealing with root
isRoot=$([[ "$source" =~ ^/root ]] &amp;&amp; echo 1 || echo 0 )


Is there a cleaner (maybe faster?) manner to assign a value to variable depending on some condition?
A clearer way would be to establish a default for the user, then locate the Bash history file for that user.

You're making the assumption that the user's home directory will be in /home, and that a root user's home directory will be /root.  That's a convention for Linux, but it won't be true at larger Linux installations, and it isn't the convention for other operating systems.  Here's one way to do the lookup for systems that use GNU libc:

user="${1-root}"
histfile="$(getent passwd "$user" | cut -d: -f6)/.bash_history"


A cross-platform way is to use tilde expansion, though the eval could be dangerous if the input is untrustworthy:

histfile=$(eval echo "~${1-root}")/.bash_history


The isRoot check should be done on the username (or UID) instead of the home directory.  It feels very unconventional to assign a boolean variable in Bash.  Keep in mind that the convention is that zero statuses are considered "true" and non-zero statuses are considered "false".  I'd advise you not to write that statement at all, but can't really advise you what to do instead since you haven't shown us what you intend to do with that variable.