This repository was archived by the owner on Sep 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313### Changed
1414* Convert conditionals to bash-native to simplify maintenance and readability
1515* Add internal logic to allow more complex prefix/suffix whitespace logic
16+ * Remove blank lines and code comments when printing bash/zsh script
1617
1718### Added
1819* Allow users to disable prompt modification with ` MAWS_PROMPT_DISABLE=1 ` .
Original file line number Diff line number Diff line change 55import platform
66import requests
77import tempfile
8+ import re
89
910from .cache import read_group_role_map , write_group_role_map
1011
1112
1213logger = logging .getLogger (__name__ )
1314
14- PROMPT_BASH_CODE = r'''
15+ # we post-process this variable in a specific manner; please take note:
16+ # 1) blank lines are removed
17+ # 2) lines that are only a # comment are removed
18+ prompt_bash_code_original = r'''
1519function maws_profile {
1620 if [[ -n $MAWS_PROMPT ]]; then
1721 # either a whitespace character or blank, depending on what
7074fi
7175'''
7276
77+ # remove blank lines and code comments from the bash script.
78+ # this permits maintainable code but minimizes what's emitted
79+ # if the user doesn't use source/eval/<() when calling maws.
80+ PROMPT_BASH_CODE = ""
81+ for line in prompt_bash_code_original .split ("\n " ):
82+ # skip blank lines and comments
83+ if not re .match ('^ *(#|$)' , line ):
84+ PROMPT_BASH_CODE += line + "\n "
7385
7486def output_set_env_vars (var_map , message = None ):
7587 if platform .system () == "Windows" :
You can’t perform that action at this time.
0 commit comments