Skip to content

Commit

Permalink
Append pid to temp files.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabdi-noaa committed Jun 15, 2022
1 parent 2084b50 commit 10de1c3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions ush/python_utils/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ def load_shell_config(config_file):
# Save env vars before and after sourcing the scipt and then
# do a diff to get variables specifically defined/updated in the script
# Method sounds brittle but seems to work ok so far
pid = os.getpid()
code = dedent(f''' #!/bin/bash
(set -o posix; set) > ./_t1
t1="./t1.{pid}"
t2="./t2.{pid}"
(set -o posix; set) > $t1
{{ . {config_file}; set +x; }} &>/dev/null
(set -o posix; set) > ./_t2
diff ./_t1 ./_t2 | grep "> " | cut -c 3-
rm -rf ./_t1 ./_t2
(set -o posix; set) > $t2
diff $t1 $t2 | grep "> " | cut -c 3-
rm -rf $t1 $t2
''')
(_,config_str,_) = run_command(code)
lines = config_str.splitlines()
Expand Down

0 comments on commit 10de1c3

Please sign in to comment.