Skip to content

Commit

Permalink
add emulate pushd and popd behavior for esm_master
Browse files Browse the repository at this point in the history
  • Loading branch information
mandresm committed Dec 11, 2024
1 parent a6d53db commit 78e8942
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/esm_master/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,8 @@ def generate_task_script(self):
def execute(self, ignore_errors=False):
# Calculate the number of get commands for this esm_master operation
self.num_of_get_commands()
# Initialize the dirstack for imitating pushd popd
dirstack = []
# Loop through the commands
for command in self.command_list:
repo = self.get_repo_properties_from_command(command)
Expand Down Expand Up @@ -481,6 +483,16 @@ def execute(self, ignore_errors=False):
command_spl = shlex.split(command)
if "cd" == command_spl[0]:
os.chdir(command_spl[1])
elif "pushd" == command_spl[0]:
# Emulates pushd (MA): yes it is horrible, but I don't
# have time to rewrite esm_master right now
dirstack.append(os.getcwd())
os.chdir(command_spl[1])
elif "popd" == command_spl[0]:
# Emulates popd (MA): yes it is horrible, but I don't
# have time to rewrite esm_master right now
target_dir = target_dir = dirstack.pop(-1)
os.chdir(target_dir)
else:
subprocess.run(
command_spl,
Expand Down

0 comments on commit 78e8942

Please sign in to comment.