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

Prefix all shell commands with backslashes to ignore aliases #65

Merged
merged 3 commits into from
Jul 4, 2021
Merged

Prefix all shell commands with backslashes to ignore aliases #65

merged 3 commits into from
Jul 4, 2021

Conversation

squatto
Copy link
Contributor

@squatto squatto commented Jun 30, 2021

I recently began using exa to replace ls. To make the switch easier, I aliased ls:

$ which ls
ls: aliased to exa --icons --classify --header --git

As a result, the command this package uses to get the latest log file (ls -t) throws an error instead of listing the sorted files:

$ ls -t
exa: Flag -t needs a value (choices: modified, changed, accessed, created)
To sort newest files last, try "--sort newest", or just "-snew"

The package uses the ls, head, tail, and grep shell commands, and they all could potentially be aliased/overwritten on the user's system. This could break the package, and there is no way of knowing because the output is suppressed:

image

This PR simply adds backslashes to the beginning of each shell command so that aliases are ignored and the native shell commands are used instead.

I can manually specify the escaped command with --file to get it to work, but it's janky and you'll only know to do it this way if you know why it's throwing the error in the first place:

php artisan tail --file="\`\\ls -t | \\head -1\`"

Thanks!

@freekmurze
Copy link
Member

It seems that this PR also contains code gormatting changes, making it harder to review.

Could you remove all code formatting changes?

@squatto
Copy link
Contributor Author

squatto commented Jul 1, 2021

Oh geez, I’m so sorry! It’s a good reminder that all of my diff tools are set to ignore whitespace changes, so I didn’t even see those formatting changes 🤦🏼‍♂️ I’ll revert everything except the actual changed lines and push.

@squatto
Copy link
Contributor Author

squatto commented Jul 1, 2021

@freekmurze The unrelated whitespace/formatting changes have been reverted 👍🏻

@freekmurze freekmurze merged commit 3d04180 into spatie:main Jul 4, 2021
@freekmurze
Copy link
Member

Thanks!

@squatto squatto deleted the ignore-shell-aliases branch July 5, 2021 15:20
@squatto
Copy link
Contributor Author

squatto commented Jul 5, 2021

My pleasure!

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