Skip to content

Conversation

@gaelicWizard
Copy link
Contributor

@gaelicWizard gaelicWizard commented Sep 7, 2021

NOTE: This PR assumes that my basenamed branch has already been merged (#1926)! This PR does not do anything with basename/dirname; it's just based off that branch.

Description

Bash maintains the $PWD shell parameter with the current and correct full path to the present working directory. The shell builtin pwd returns the value of $PWD, so just skip the subshell and use the parameter directly.

Motivation and Context

This is part of a patch set to reduce the use of subshells.

How Has This Been Tested?

Tested locally, and all tests pass.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
    ...more of an optimization.

Checklist:

  • My code follows the code style of this project.
  • If my change requires a change to the documentation, I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • If I have added a new file, I also added it to clean_files.txt and formatted it using lint_clean_files.sh.
  • I have added tests to cover my changes, and all the new and existing tests pass.

@gaelicWizard
Copy link
Contributor Author

gaelicWizard commented Sep 10, 2021

This draft is actually ready to review assuming that my basename PR (#1926) is accepted. Anyone feel like taking a look before the other is merged? 😃

@gaelicWizard gaelicWizard mentioned this pull request Sep 10, 2021
6 tasks
@gaelicWizard gaelicWizard changed the title DRAFT: Use $PWD instead of $(pwd) Use $PWD instead of $(pwd) Sep 12, 2021
@gaelicWizard
Copy link
Contributor Author

I'm marking this ready-for-review, but do please note that it looks larger than it is since this PR is based on the same basenamed (#1926) branch.

@gaelicWizard gaelicWizard marked this pull request as ready for review September 12, 2021 03:53
@gaelicWizard gaelicWizard force-pushed the pwd branch 3 times, most recently from 3cf7c47 to e0ae8a6 Compare September 16, 2021 23:59
Copy link
Member

@NoahGorny NoahGorny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, after merging #1926 of course 😄

Don't subshell when there's a shell parameter for it.
Don't subshell when there's a shell parameter for it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants