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

test to [[ where available #261

Draft
wants to merge 22 commits into
base: master
Choose a base branch
from
Draft

test to [[ where available #261

wants to merge 22 commits into from

Conversation

balupton
Copy link
Member

@balupton balupton commented Oct 28, 2024

This convention change improves performance and resolves edge cases when test -n "$a" -a "$b" = "$c" where a=>.

fixes:

  • init.sh: fix a missing -d
  • github-download: fix a missing -n
  • is-missing: fix incorrect help text on exit status
  • mount-helper: fix two missing -n, one of them seems better to not exist (as we should always just want the first line in that case)
  • setup-git: fix a missing test/[[
  • waiter: fix missing -n

other changes:

  • add is-(directory|file|missing|not-directory|present|readable)(.bash)?, such that sudo doesn't have to call problematic test command

todos:

  • note this change of convention in the docs
  • review the PR to check if there were any errors

fixes:

- init.sh: fix a missing `-d`
- github-download: fix a missing `-n`
- mount-helper: fix a missing `-n`
- setup-git: fix a missing `test`/`[[`
- waiter: fix missing `-n`

todos:

- note this change of convention in the docs
- see if there is an alternative for the sudo calls
- review the PR to check if there were any errors
@balupton balupton marked this pull request as draft October 28, 2024 12:03
@balupton balupton self-assigned this Oct 28, 2024
- add `is-(directory|file|missing|not-directory|present|readable)(.bash)?`
- is-missing: fix incorrect help text on exit status
- mount-helper: fix missing `-n`, however seems better to just always fetch a single line here
- debug-network: fix WIP commit using `[[` in a sh script, instead of `[`
- `while true` to `while :`, and `true` to `:` where appropriate
- brew: compact a conditional
- (choose|config-helper|confirm|echo-lines|is-empty-value|setup-(git|linux|mac|system)): compact an or conditional
- is-suffix: update for `__substr` shim in `bash.bash` for bash v3 support
- `is-dir`: move to deprecated, as there is now `is-directory`
bg="${bg##*;}" # trim everything prior to the last ;
if test "$bg" = 'default' || test "$bg" -le 6 -o "$bg" -eq 8; then
if [[ $bg == 'default' ]] || (is-digit -- "$bg" && [[ $bg -le 6 || $bg -eq 8 ]]); then
Copy link
Member Author

Choose a reason for hiding this comment

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

the introduction of is-digit here is a sanity check to prevent weird behaviour

todos:

- choose: needs truncating of choose body, if too long, possible with `fs-rm` and `fs-trim` with large directory content listing: `eza -lA | sed -e '5,$d' -e '4,$s/.*/Truncated./'` is suitable, however our own command would work
- eval-helper: check if pending/success/failure messages are still going to TTY
- is-not-symlink: update copy and pasted tests to match its functionality
- consider renames of `echo-exit-affirmative`, `echo-exit-status`, `is-root`

changes:

- choose:
    - optional will now cancel to nothing, only required cancels to defaults
    - can now press R to revert to defaults
- dorothy:
    - permissions action no longer trims junk files, as they are already git-ignored
- `fs-realpath`, `fs-structure`, `fs-trim`, `is-broken-symlink`, `is-directory`, `is-empty-directory`, `is-empty-file`, `is-file`, `is-missing`, `is-not-directory`, `is-not-symlink`, `is-present`, `is-readable`, `is-symlink`, `is-nonempty-file`:
    - support `--(sudo|user|group)` arguments
    - consistent internal structure
    - add tests where appropriate
- `fs-rm`, `fs-trim`, `fs-structure`:
    - rewrote `fs-rm` for new `fs-trim` command, with exact prompts on what to do, no longer overly complex and fragile
    - rewrote `fs-structure` to prefer `exa`, comment out verbose `dust`/`du` handling as `exa` is better and more understandable for this use case, made perms and time toggles
- fs-temp:
    - clarified touch functionality (will make directories, but not files, by default), make `--no-touch` not make directories
- add `fs-trim`:
    - consolidated functionality from: `fs-rm`, `rm-junk`, `rm-modules`
    - clear handling of symlinks
- add `is-broken-symlink`, `is-empty-directory`, `is-empty-file`, `is-not-symlink`, `is-file`, `is-not-symlink`, `is-symlink`:
- is-generic:
    - change return status behaviour on multiple arguments to be consistent with others
- promoted `is-even` from beta commands
- add `setup-util-qpdf` for `pdf-decrypt`, and updated `pdf-decrypt` for modern covnentions
- sudo-helper:
    - add `--[no-]sudo` flag, which if no and no user nor group, then no sudo is needed

fixes:

- choose: pressing escape/q to cancel now works again
- echo-values: fix help text being incorrect
- eval-helper: wrapping will now have wraps go to stdout
- get-terminal-theme: more accurate parsing of `COLORFGBG`
- is-admin: fix multiple users handling
- setup-dns: improve handling of bad interfaces fetch

renames and deprecations:

- `is-nonempty-string` to `is-not-whitespace`
- `is-empty-string` to `is-whitespace`
- `is-empty-ls` to `is-empty-directory`, turns out we had two commands doing the same thing
- `is-dir` to `is-directory`
- `is-either` to `is-needle`, `is-neither` to `! is-needle`
- `echo-if-empty` to `echo-with-whitespace-fallback`, added `echo-with-empty-fallback` for zero-length
- `echo-values` promoted from beta, used within `setup-dns`
- `fs-size` deprecated as it was the same as `fs-structure`; use `fs-structure` or `get-size` instead
- `rm-vmware` to `rm-vmware-fusion`
- `rm-junk` and `rm-modules` to `fs-trim --junk`
- deprecate `is-array-*` and `get-array-*` commands
- deprecate `is-exec`, `is-equal`, `rm-svn`, and `rm-sync` until there is a use case for them

linting:

- down: as `fs-temp` touch usage is now clarified, improve logic around mkdirp call
- fs-filename: use the new options help text format
- get-terminal-color-support: fix return status help text
- remove unnecessary `--status=0` in `eval-tester` calls
- improve wording of return statuses in help text
- improve wording around whether symlinks are considered or not in various commands
- added `Companion to ...` line to improve discovery of (related) commands and their functionality
@balupton balupton force-pushed the dev/square-brackets branch from 2538a59 to ccda6c8 Compare November 16, 2024 04:27
- choose: add `--truncate-body` WIP
- config-edit: `--editer=` to `--editor=`
- add `echo-truncate-lines` WIP
- eval-helper: shapeshifter will be enabled on `sudo-helper` by default
- flush-dns, setup-util-docker, setup-util-xcode: fix formatting when sudo needed
- fs-rm: rewrote for new `fs-trim` command
- get-profile: `possesive-pronoun` to `possesive-pronoun`
- git-helper: fix bad formatting on failures
- is-present: speedier sudo checks, by first checking without sudo
- sudo-helper: support `--optional` for speedier checks without sudo
- mount-helper: fixed detection of forced unmount
- add `setup-util-tor-browser`
- styles: fix terminal title and resize not terminating
@balupton balupton force-pushed the dev/square-brackets branch 3 times, most recently from 9f7e1e8 to 808f55c Compare November 27, 2024 10:18
@balupton balupton force-pushed the dev/square-brackets branch from 808f55c to b96a30f Compare November 27, 2024 10:25
@balupton balupton force-pushed the dev/square-brackets branch from 5cc1ae7 to 839a82c Compare November 27, 2024 12:11
@balupton balupton requested a review from Copilot November 27, 2024 12:11

Choose a reason for hiding this comment

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

Copilot reviewed 559 out of 576 changed files in this pull request and generated no suggestions.

Files not reviewed (17)
  • .vscode/workspace.code-workspace: Language not supported
  • commands.beta/convert-helper: Language not supported
  • commands.beta/echo-affirmative: Language not supported
  • commands.beta/echo-escape-special: Language not supported
  • commands.beta/echo-exit-affirmative: Language not supported
  • commands.beta/echo-exit-status: Language not supported
  • commands.beta/echo-html-coder.recode: Language not supported
  • commands.beta/echo-html-coder.textutil: Language not supported
  • commands.beta/echo-html-coder.xmlstarlet: Language not supported
  • commands.beta/echo-if-directory: Language not supported
  • commands.beta/echo-if-executable: Language not supported
  • commands.beta/echo-if-path: Language not supported
  • commands.beta/echo-last-line: Language not supported
  • commands.beta/echo-mkdir: Language not supported
  • commands.beta/echo-non-affirmative: Language not supported
  • commands.beta/echo-nonflags: Language not supported
  • commands.beta/echo-nothing-or-fail: Language not supported
- add `echo-if-directory`, `echo-if-executable`, `echo-if-present`, `is-executable`, `is-writable`
- `echo-if-file`, `fs-dequarantine` now consistent with other such helpers
- fs-trim: fix bad filename code handling, use new `is-needle` flags
- is-needle: add `--ignore-case`, `--all`, `--any` flags, and enforce expected arg usage
- setup-dns: simplify `fs-rm` call as the extra stuff is no longer necessary
- setup-util-bash: simplify `is-needle` call
- echo-truncate-lines: move to beta, as no active users
- setup-server: use fs helpers wherever appropriate
- deprecate `echo-if-path` for `echo-if-present`
@balupton balupton force-pushed the dev/square-brackets branch 3 times, most recently from 2e4f695 to 72339a7 Compare November 29, 2024 10:07
@balupton balupton force-pushed the dev/square-brackets branch 2 times, most recently from dffa6fc to dcb21f4 Compare November 29, 2024 11:33
@balupton balupton force-pushed the dev/square-brackets branch from dcb21f4 to 13c335f Compare November 29, 2024 12:15
@balupton balupton force-pushed the dev/square-brackets branch from 13c335f to 3db5aba Compare November 29, 2024 12:20
@balupton balupton force-pushed the dev/square-brackets branch from c1a9454 to ad5887c Compare November 30, 2024 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant