Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env.sh: prefer readlink to cd && echo ${PWD} #5162

Merged
merged 1 commit into from
Feb 29, 2024
Merged

env.sh: prefer readlink to cd && echo ${PWD} #5162

merged 1 commit into from
Feb 29, 2024

Conversation

dancrossnyc
Copy link
Contributor

A trivial change to make this script more robust for those of us who alias cd to something.

@dancrossnyc dancrossnyc enabled auto-merge (squash) February 28, 2024 22:00
@dancrossnyc dancrossnyc disabled auto-merge February 28, 2024 22:00
A trivial change to make this script more robust for those
of us who alias `cd` to something.
@dancrossnyc dancrossnyc changed the title env.sh: preer readlink to cd && echo ${PWD} env.sh: prefer readlink to cd && echo ${PWD} Feb 28, 2024
@dancrossnyc dancrossnyc enabled auto-merge (squash) February 28, 2024 22:03
@jclulow
Copy link
Collaborator

jclulow commented Feb 29, 2024

Perhaps just use builtin cd to avoid alias expansion?

@dancrossnyc
Copy link
Contributor Author

Perhaps just use builtin cd to avoid alias expansion?

I considered that, as well as using the chdir builtin, that's unlikely to be aliased. But I couldn't really see an advantage over readlink, which seems to be readily available pretty much everywhere. What's the advantage?

@dancrossnyc dancrossnyc merged commit 10ada76 into main Feb 29, 2024
20 checks passed
@dancrossnyc dancrossnyc deleted the env branch February 29, 2024 16:44
@jclulow
Copy link
Collaborator

jclulow commented Feb 29, 2024

It requires a fork, and it depends on GNU coreutils I believe; we don't have a readlink in the base tools.

In this case I suppose it doesn't matter hugely, but the pattern used here is one we use in a lot of bash scripts all over the place -- so as long as we don't start changing all the other ones.

@dancrossnyc
Copy link
Contributor Author

The forks are the same (the subcommand for $() is already run in a child process, of course), but it does add an exec. Yeah, I wondered about the coreutils thing.

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.

3 participants