you could have done the previous commands in a sub-shell (similar to a with context in Python, your pwd is retrieved when you exit the subshell), but this is also fine.