sh_helper

Shell script variable support. Read and write syntax like export key="value" in shell script.

pysecret.sh_helper.export_pattern = re.compile('export [a-zA-Z0-9_]{1,128}="[\\d\\D]{1,128}"')

Limitation, key, value length can’t be greater than 128.

pysecret.sh_helper.append_line_if_not_exists(path: str, line: str)[source]

Append a line to a text file at path if the line not exists in its content.

Parameters
  • path – text file absolute path

  • line – text string.

Returns

None

pysecret.sh_helper.load_var_value_from_shell_script_content(content: str) dict[source]

Extract variable definition such as export var="value" from shell script content text.

Parameters

content – text content of a shell script

Returns

pysecret.sh_helper.load_var_value_from_shell_script(path_shell_script: str) dict[source]

Extract export key="value" key value data from a shell script.

Parameters

path_shell_script – shell script absolute path

Returns

key value pair dictionary data