#724 PR closed
: Save and restore bash flags and options settings¶
jsmeix opened issue at 2015-12-01 16:09:¶
Implemented simple functions GetBashFlagsAndOptionsCommands
and ApplyBashFlagsAndOptionsCommands that are used
in a fail-safe way via an explicit variable that stores the
current bash flags and options commands and using
that explicit variable to re-apply them, i.e. like
saved_flags_options_cmds="$( GetBashFlagsAndOptionsCommands )" ... [change bash flags and options] ... [do something] ApplyBashFlagsAndOptionsCommands "$saved_flags_options_cmds"
See https://github.com/rear/rear/issues/700
jsmeix commented at 2015-12-01 16:11:¶
Oops!
This pull request has documentation stuff from my other pull request mixed in.
I will close this broken pull request.
schlomo commented at 2015-12-01 17:03:¶
Cool. Can you please use
small_letters_and_words_separated_by_underscore
function naming?
More consistent with the remaining ReaR code.
jsmeix commented at 2015-12-02 08:22:¶
Oops2!
I used function names as in _input-output-functions.sh
but
https://github.com/rear/rear/wiki/Coding-Style
makes it clear:
Function names are lower case, words separated by underline (_)
Now I wonder if - and if yes - how to distinguish function names
from variable names?
Globally used variables are uppercase (with words separated by underline '_') like SHARE_DIR DISKLAYOUT_FILE RECOVERY_FS_ROOT
Locally used varaiables should be lowercase and marked with "local" (also words separated by underline '_') like "local backup_path" or "local syslinux_modules_dir".
I think distinguishing functions from variables is obvious from the context how they are used so that both can have same syntax.
I wonder if we should distinguish globally used functions from locally used functions by their naming syntax?
E.g. leading capitals for words in globally used functions like
function Globally_Used_Function () { ... }
in contrast to
function locally_used_function () { ... } . . . locally_used_function ... . . . unset -f locally_used_function
schlomo commented at 2015-12-02 09:42:¶
Do we actually have a problem here? I would like to keep the rules to the absolue minimum...
jsmeix commented at 2015-12-02 10:29:¶
I do not have a problem. I was only wondering and therefore I asked.
In https://github.com/rear/rear/pull/726 I use the function names get_bash_flags_and_options_commands and apply_bash_flags_and_options_commands
[Export of Github issue for rear/rear.]