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

🐛 Use POSIX-compliant tail syntax #418

Merged
merged 2 commits into from Nov 2, 2021
Merged

🐛 Use POSIX-compliant tail syntax #418

merged 2 commits into from Nov 2, 2021

Conversation

jlec
Copy link
Contributor

@jlec jlec commented Sep 28, 2021

homebrew allows using gnu coreutils on MacOS. Therefore we should
comply with posix standards

$ mas help | tail +3
tail: cannot open '+3' for reading: No such file or directory
$ type tail
tail is /usr/local/opt/coreutils/libexec/gnubin/tail

Switching to posix compliant -n syntax is compatible with UNIX and GNU tooling.

$ mas help | /usr/bin/tail -n +3 | wc -l
18
$ mas help | tail -n +3 | wc -l
18

homebrew allows using gnu coreutils on MacOS. Therefore we should
comply with posix standards

```bash
$ mas help | tail +3
tail: cannot open '+3' for reading: No such file or directory
$ type tail
tail is /usr/local/opt/coreutils/libexec/gnubin/tail
```

Switching to posix compliant `-n` syntax is compatible with UNIX and GNU tooling.

```bash
$ mas help | /usr/bin/tail -n +3 | wc -l
18
$ mas help | tail -n +3 | wc -l
18
```
@@ -9,7 +9,7 @@ _mas() {
_get_comp_words_by_ref cur prev words cword
fi
if [[ $cword -eq 1 ]]; then
COMPREPLY=($(compgen -W "$(mas help | tail +3 | awk '{print $1}')" -- "$cur"))
COMPREPLY=($(compgen -W "$(mas help | tail -n +3 | awk '{print $1}')" -- "$cur"))

Choose a reason for hiding this comment

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

Prefer mapfile or read -a to split command output (or quote to avoid splitting).

@phatblat phatblat added this to the Unreleased milestone Oct 20, 2021
Copy link
Contributor

@chris-araman chris-araman left a comment

Choose a reason for hiding this comment

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

Thanks, @jlec!

@chris-araman chris-araman enabled auto-merge (rebase) November 2, 2021 04:56
@chris-araman chris-araman changed the title Use posix compliant tail syntax 🐛 Use posix compliant tail syntax Nov 2, 2021
@chris-araman chris-araman changed the title 🐛 Use posix compliant tail syntax 🐛 Use POSIX-compliant tail syntax Nov 2, 2021
@chris-araman chris-araman merged commit 7fe27fc into mas-cli:main Nov 2, 2021
@jlec jlec deleted the posix_tail branch November 17, 2021 21:00
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.

None yet

4 participants