Last active
June 12, 2018 17:11
-
-
Save mpapis/3044226 to your computer and use it in GitHub Desktop.
clean if statements in shell
This file contains 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
# dens form for short statements / commands | |
if [[ -n "${bla:-}" ]] | |
then x=bla | |
else x= | |
fi | |
# sparse form for long statements / more commands | |
if | |
[[ -n "${bla_asd_sf_affdfs_dsf_sdf_sdf:-}" ]] || | |
[[ -n "${bar_Dfs_dsg_FG_fd_fd_df_dfgdf:-}" ]] | |
then | |
some more commands | |
and even more | |
else | |
or other commands | |
fi | |
# mixed for large else | |
if [[ -n "${bla:-}" ]] | |
then x=bla | |
else | |
x=... | |
some more commands | |
and even more | |
fi | |
# just else | |
[[ -n "${bla:-}" ]] || | |
{ | |
x=... | |
some more commands | |
and even more | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment