New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get and apply bash flags and options settings #726
Merged
gdha
merged 5 commits into
rear:master
from
jsmeix:get_and_apply_bash_flags_and_options_settings
Dec 3, 2015
Merged
Get and apply bash flags and options settings #726
gdha
merged 5 commits into
rear:master
from
jsmeix:get_and_apply_bash_flags_and_options_settings
Dec 3, 2015
Conversation
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
functionality for bash flags and options settings, see rear#700
in usr/share/rear/lib/framework-functions.sh which should obsolete the DEBUGSCRIPTS_OPPOSITE_ARGUMENT workaround, see rear#700
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" In contrast using implicitly a stack of saved_flags_options_cmds via SaveFlagsAndOptions and RestoreFlagsAndOptions functions is not equally fail-safe because one must carefully ensure that each element that is put onto the stack via SaveFlagsAndOptions gets removed later via RestoreFlagsAndOptions, e.g. SaveFlagsAndOptions ... [change bash flags and options] ... [do something] if <condition> ; then SaveFlagsAndOptions ... [change bash flags and options] ... [do something] fi ... [do something] RestoreFlagsAndOptions restores wrong flags and options in case of <condition>. Furthermore using implicitly a stack of saved_flags_options_cmds makes it complicated to restore an explicity named state or to simply restore a specific state several times like: initial_flags_options_cmds="$( GetBashFlagsAndOptionsCommands )" ... [change bash flags and options] ... [do something] if <condition> ; then saved_flags_options_cmds="$( GetBashFlagsAndOptionsCommands )" ... [change bash flags and options] ... [do something] ApplyBashFlagsAndOptionsCommands "$saved_flags_options_cmds" ... [do something] fi ApplyBashFlagsAndOptionsCommands "$initial_flags_options_cmds" ... [do something] ... [change bash flags and options] ... [do something] ApplyBashFlagsAndOptionsCommands "$initial_flags_options_cmds"
and apply_bash_flags_and_options_commands 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="$( get_bash_flags_and_options_commands )" ... [change bash flags and options] ... ... [do something] ... apply_bash_flags_and_options_commands "$saved_flags_options_cmds" In contrast using implicitly a stack of saved_flags_options_cmds via save_flags_and_options and restore_flags_and_options functions is not equally fail-safe because one must carefully ensure that each element that is put onto the stack via save_flags_and_options gets removed later via restore_flags_and_options, i.e. the save_flags_and_options and restore_flags_and_options function calls must be carefully balanced in any case in all scripts, e.g. the following loppy code restores wrong flags and options in case of <condition>: save_flags_and_options ... [change bash flags and options] ... ... [do something] ... if <condition> ; then save_flags_and_options ... [change bash flags and options] ... ... [do something] ... fi ... [do something] ... restore_flags_and_options Furthermore using implicitly a stack of saved_flags_options_cmds makes it complicated to restore an explicity named state or to simply restore a specific state several times like: initial_flags_options_cmds="$( get_bash_flags_and_options_commands )" ... [change bash flags and options] ... ... [do something] ... if <condition> ; then saved_flags_options_cmds="$( get_bash_flags_and_options_commands )" ... [change bash flags and options] ... ... [do something] ... apply_bash_flags_and_options_commands "$saved_flags_options_cmds" ... [do something] ... fi apply_bash_flags_and_options_commands "$initial_flags_options_cmds" ... [do something] ... ... [change bash flags and options] ... ... [do something] ... apply_bash_flags_and_options_commands "$initial_flags_options_cmds" Finally, if using implicitly a stack of saved_flags_options_cmds via save_flags_and_options and restore_flags_and_options functions is really needed, it can be implemented later as an enhancement that is based on the simple functions get_bash_flags_and_options_commands and apply_bash_flags_and_options_commands.
This was referenced Dec 2, 2015
@jsmeix I'm good with your enhancements - perhaps if I need to say something - add a remark in the main script that functions belong the the library scripts, but that these 2 are exceptions on the rule. |
belong to the library scripts, but that these 2 are exceptions, and added myself (jsmeix) to the AUTHORS list in usr/sbin/rear
gdha
added a commit
that referenced
this pull request
Dec 3, 2015
…ons_settings Get and apply bash flags and options settings
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implemented simple functions get_bash_flags_and_options_commands
and apply_bash_flags_and_options_commands 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
Currently those functions are used in framework-functions.sh
when "Entering debugscripts mode" and "Leaving debugscripts mode"
so that the workaround by using DEBUGSCRIPTS_OPPOSITE_ARGUMENT is obsoleted.
See #700