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 57 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
4627b75
`test` to `[[` where available
balupton Oct 28, 2024
c2f2ca9
move sudo calls to `[[` helpers
balupton Oct 29, 2024
3bf0e55
ci: linting
balupton Oct 29, 2024
75a30d7
ci: linting
balupton Oct 29, 2024
ef8a387
ci: linting
balupton Oct 29, 2024
ccda6c8
fs-* command consistency
balupton Nov 16, 2024
25fa014
spellcheck, fixes, improvements
balupton Nov 27, 2024
b96a30f
attempt fix apt failures:
balupton Nov 27, 2024
e0cd9a0
ci: fix remaining spellcheck issues
balupton Nov 27, 2024
839a82c
fs-trim: split junk into cache and module
balupton Nov 27, 2024
b624ee8
echo-if-*, if-*, is-needle: consistency
balupton Nov 29, 2024
f8eb322
promote `eval-on-empty-stdin`, `eval-on-not-empty-stdin`
balupton Nov 29, 2024
6ffa78c
ci: debug `fs-trim` failures
balupton Nov 29, 2024
3db5aba
fs-trim: still failing, try alternative to `eval-on-empty-stdin`
balupton Nov 29, 2024
ad5887c
fs-rm, fs-trim: prevent erasure of CWD
balupton Nov 30, 2024
db0187d
setup-util: better APT_REPO http check formatting
balupton Nov 30, 2024
88c9a33
setup-util-eza: use HTTPS for APT_REPO
balupton Nov 30, 2024
55ee7e6
fs-trim: fix tests
balupton Nov 30, 2024
af962c5
fs-trim: remove linux rm wrapping
balupton Nov 30, 2024
cfec77c
ci: attempt fix fedora
balupton Nov 30, 2024
c4d9ac6
now that fs-trim tests work, re-enable all tests
balupton Nov 30, 2024
b06ce34
fs-structure: handle missing and empty paths
balupton Nov 30, 2024
bbf7e17
redo `is-*` commands, redo `fs-rm`, add `dorothy commands`
balupton Jan 1, 2025
664120d
Merge branch 'master' into dev/square-brackets
balupton Jan 1, 2025
3aa038f
ci: adjustments
BevryMe Jan 1, 2025
365c189
ci: macos-12 is deprecated, replace with macos-13
balupton Jan 1, 2025
cf10395
ci: spell linting
balupton Jan 1, 2025
cca8f9b
fs-rm, setup-util-trash: fix macos support
balupton Jan 2, 2025
872f0b7
- eval-helper: fix sudo-helper --wrap not showing the command
balupton Jan 6, 2025
84768eb
- eval-helper: fix `echo-revolving-door` ansi escape codes ending up …
balupton Jan 6, 2025
d7b48ff
is-accessible, tests.bash: fix root user on CI
balupton Jan 7, 2025
964bf20
is-root: add tests, support options
balupton Jan 7, 2025
b2c0065
is-root: promote from beta
balupton Jan 7, 2025
268afa4
is-root: add sudo tests
balupton Jan 7, 2025
39b921d
tests.bash: continue debugging by continuing tests despite failure, b…
balupton Jan 7, 2025
1f6b37b
is-accessible, tests.bash: group tests
balupton Jan 7, 2025
bef3016
rethink fs-* and sudo-helper escalations
balupton Jan 8, 2025
bd7019f
is-accessible, tests: more updates
balupton Jan 8, 2025
22b480e
tests.bash: try `root:root` instead of `root:`
balupton Jan 8, 2025
b073dec
fs-own, tests: more attempts to resolve root tests weirdness
balupton Jan 8, 2025
49f5ca1
edit: don't dump [None of the configured editors were available] erro…
balupton Jan 8, 2025
b446b97
fs-structure: eza: show groups if no permissions
balupton Jan 8, 2025
5ce4b8b
ci: only run some of the tests as this is taking too long
balupton Jan 8, 2025
5c701ec
fs-own, tests: mode debugging of tests
balupton Jan 8, 2025
d5d12bc
tests: [chown -n 0:0] doesn't work on linux
balupton Jan 8, 2025
ec9ef68
tests: fix bad fs-structure call
balupton Jan 8, 2025
4bf4b83
more debugging
balupton Jan 8, 2025
68d7252
finally got to the bottom of it, linux has a different format for rep…
balupton Jan 8, 2025
cc8af12
dorothy: test and lint by most recently modified first
balupton Jan 8, 2025
eaefcec
setup-util: quiet font installs are now quiet
balupton Jan 10, 2025
0031c62
is-broken-symlink, is-directory: use new `tests.bash`
balupton Jan 10, 2025
2e79948
add `is-owner`, fix typo in `tests.bash`, expand `tests.bash` to more…
balupton Jan 13, 2025
e05fa9c
dorothy: apply commit modification times instead of clone
balupton Jan 13, 2025
23ab815
docs: update internal docs to mention new alternatives
balupton Jan 14, 2025
399531a
dorothy, git-helper: use `git-helper umt` on ci
balupton Jan 14, 2025
30ef3db
git-helper: simpler `umt` action
balupton Jan 14, 2025
e3b8fc4
down: note tool that was used, disable wget progress bar on ci or via…
balupton Jan 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 7 additions & 8 deletions .github/workflows/dorothy-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ jobs:
strategy:
fail-fast: false
matrix:
runner: [ubuntu-24.04, ubuntu-22.04, macos-15, macos-14, macos-12]
runner: [ubuntu-24.04, ubuntu-22.04, macos-15, macos-14, macos-13]
# ubuntu-20.04 not supported, echo-wait fails: https://github.com/bevry/dorothy/actions/runs/9705310169/job/26787151094#step:2:1346
runs-on: ${{ matrix.runner }}
steps:
Expand All @@ -178,7 +178,7 @@ jobs:
strategy:
fail-fast: false
matrix:
runner: [macos-15, macos-14, macos-12]
runner: [macos-15, macos-14, macos-13]
runs-on: ${{ matrix.runner }}
steps:
- name: 'Uninstall Homebrew'
Expand Down Expand Up @@ -235,17 +235,16 @@ jobs:
elif command -v urpmi; then
# for mageia, prefer over fedora as mageia also contains dnf
# https://wiki.mageia.org/en/Cauldron
# --allowerasing needed due to: https://github.com/bevry/dorothy/actions/runs/6033044029/job/16369147940
# https://github.com/bevry/dorothy/actions/runs/6033044029/job/16369147940
# https://github.com/bevry/dorothy/actions/runs/6033557632/job/16370418074
# urpmi --auto-update --auto
# dnf check-update --assumeyes
# dnf upgrade --assumeyes --refresh --best --allowerasing
# ^ disabled as always fails
urpmi.update -a
# ^ this fails too: https://github.com/bevry/dorothy/actions/runs/6033557632/job/16370418074
urpmi --auto bash curl
elif command -v dnf; then
# for fedora
dnf --assumeyes --refresh --best --allowerasing install bash curl
# dnf check-update --assumeyes
# dnf upgrade --assumeyes --refresh --best --allowerasing
dnf install --assumeyes --refresh --best --allowerasing bash curl
elif command -v xbps-install; then
# for void linux
xbps-install --sync --update --yes xbps
Expand Down
27 changes: 15 additions & 12 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# https://features.trunk.io/check/p/trunk-doesnt-work-in-nested-repo
version: 0.1
cli:
version: 1.21.0
version: 1.22.8
plugins:
sources:
- id: trunk
ref: v1.4.5
ref: v1.6.5
uri: https://github.com/trunk-io/plugins
runtimes:
enabled:
- [email protected]
- [email protected]
- [email protected]
# - [email protected] <-- there's only a single Node.js file: echo-url-coder.js
Expand All @@ -20,20 +21,22 @@ actions:
- trunk-upgrade-available
lint:
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- git-diff-check@SYSTEM
- gitleaks@8.18.2
- gitleaks@8.21.2
- [email protected]
- markdownlint@0.39.0
- prettier@3.2.5
- ruff@0.3.4
- markdownlint@0.43.0
- prettier@3.4.0
- ruff@0.8.0
- [email protected]
- [email protected]
- taplo@0.8.1
- trufflehog@3.71.0
- taplo@0.9.3
- trufflehog@3.84.1
- [email protected]
disabled:
- eslint # it can't find the bevry config extensions for some reason
Expand Down
23 changes: 3 additions & 20 deletions .vscode/workspace.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,8 @@
}
],
"settings": {
"cSpell.words": [
"balupton",
"Bash",
"Builtins",
"doas",
"dotfile",
"dotfiles",
"Mageia",
"molleweide",
"pacman",
"POSIX",
"Roadmap",
"Subshells",
"sumitrai",
"xbps",
"Xonsh",
"Zsh",
"Bevry"
],
"deno.enable": true
"prettier.enable": false,
"cSpell.enabled": true,
"deno.enable": true
}
}
4 changes: 2 additions & 2 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

Unless stated otherwise all works are:

- Copyright &copy; [Benjamin Lupton](https://balupton.com)
- Copyright &copy; [Benjamin Lupton](https://balupton.com)

and licensed under:

- [Reciprocal Public License 1.5](http://spdx.org/licenses/RPL-1.5.html)
- [Reciprocal Public License 1.5](http://spdx.org/licenses/RPL-1.5.html)

## Reciprocal Public License 1.5 (RPL1.5)

Expand Down
266 changes: 133 additions & 133 deletions README.md

Large diffs are not rendered by default.

44 changes: 22 additions & 22 deletions commands.beta/convert-helper
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ function convert_helper() (
EXAMPLE:
convert-helper --podaudio -- *.wav
EOF
if test "$#" -ne 0; then
if [[ $# -ne 0 ]]; then
echo-error "$@"
fi
return 22 # EINVAL 22 Invalid argument
}

# process
local item files=() action='' option_stereo='' option_mono='' option_timestamp='' option_delete='no' option_transcribe='no' option_trim_trailing_silence='no'
while test "$#" -ne 0; do
while [[ $# -ne 0 ]]; do
item="$1"
shift
case "$item" in
Expand Down Expand Up @@ -134,77 +134,77 @@ function convert_helper() (
cd "$dir" || return
filename="$(fs-filename -- "$path")"
extension="$(fs-extension -- "$path")"
if test -n "$option_timestamp"; then
if [[ -n $option_timestamp ]]; then
# prefix filename with timestamp
if test "$option_timestamp" = 'yes'; then
if [[ $option_timestamp == 'yes' ]]; then
filename="$(date-helper --8601 | echo-regexp -g ':' '-') $filename"
else
filename="$(date-helper --8601 | echo-regexp -g ':' '-') $option_timestamp"
fi
cp "$path" "$filename.$extension"
path="$filename.$extension"
fi
if test "$option_trim_trailing_silence" = 'yes'; then
if [[ $option_trim_trailing_silence == 'yes' ]]; then
outfile="$filename [trimmed].m4a"
run ffmpeg -y -i "$path" -af 'silenceremove=stop_periods=-1:stop_duration=0.5:stop_threshold=-60dB' "$outfile"
if test "$option_delete" = 'yes'; then
fs-rm --no-confirm --quiet -- "$path"
if [[ $option_delete == 'yes' ]]; then
fs-rm --quiet --no-confirm -- "$path"
fi
filename="$filename [trimmed]"
path="$outfile"
fi
if test "$action" = 'podaudio'; then
if test -z "$option_stereo" -a -z "$option_mono"; then
if [[ $action == 'podaudio' ]]; then
if [[ -z $option_stereo && -z $option_mono ]]; then
if is-audio-stereo -- "$path"; then
use_stereo='yes'
else
use_mono='yes'
fi
fi
if test "$use_stereo" = 'yes'; then
if [[ $use_stereo == 'yes' ]]; then
outfile="$filename [aac_he_v2] [48k] [stereo].m4a"
run ffmpeg -y -i "$path" -c:a libfdk_aac -profile:a aac_he_v2 -b:a 48k "$outfile"
fi
if test "$use_mono" = 'yes'; then
if [[ $use_mono == 'yes' ]]; then
outfile="$filename [aac_he_v1] [48k] [mono].m4a"
run ffmpeg -y -i "$path" -ac 1 -c:a libfdk_aac -profile:a aac_he -b:a 48k "$outfile"
fi
elif test "$action" = 'podvideo'; then
elif [[ $action == 'podvideo' ]]; then
outfile="$filename [h264].mp4"
run ffmpeg -y -i "$path" -c:v libx264 -c:a libfdk_aac "$outfile"
elif test "$action" = 'alac'; then
elif [[ $action == 'alac' ]]; then
outfile="$filename.m4a"
run ffmpeg -y -vn -i "$path" -c:a alac "$outfile"
elif test "$action" = 'split'; then
elif [[ $action == 'split' ]]; then
run ffmpeg -y -i "$path" -map 0:0 -map 0:2 -c copy "$filename [00+02].mov"
run ffmpeg -y -i "$path" -map 0:1 -map 0:3 -c copy "$filename [01+03].mov"
# elif test "$action" = 'trim'; then
# elif [[ "$action" = 'trim' ]]; then
# # Trim superfluous audio streams from a video file
# help 'trim action not yet finished'
# # run ffmpeg -i "$input" -c copy -an "$output"
# # run ffmpeg -i "$input" -c copy -map 0:v -map "0:a:$stream" "$output"
# elif test "$action" = 'thumbnail'; then
# elif [[ "$action" = 'thumbnail' ]]; then
# help 'thumbnail action not yet finished'
# # outfile="$filename.jpg"
# # run ffmpeg -y -i "$path" -vf "thumbnail" -frames:v 1 "$outfile"
# # run ffmpeg -i "$1" -i "$2" -map 0 -map 1 -c copy -c:v:1 avif -disposition:v:1 attached_pic out.webm
elif test "$action" = 'png'; then
elif [[ $action == 'png' ]]; then
outfile="$filename.png"
run sips -s format png "$path" --out "$outfile"
elif test -n "$action"; then
elif [[ -n $action ]]; then
help 'Unknown action'
fi
if test "$option_transcribe" = 'yes'; then
if [[ $option_transcribe == 'yes' ]]; then
outfile="$filename.srt"
whisper --model base --language English --output_format srt "$path"
fi
if test "$option_delete" = 'yes'; then
fs-rm --no-confirm --quiet -- "$path"
if [[ $option_delete == 'yes' ]]; then
fs-rm --quiet --no-confirm -- "$path"
fi
done
)

# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
if [[ $0 == "${BASH_SOURCE[0]}" ]]; then
convert_helper "$@"
fi
11 changes: 5 additions & 6 deletions commands/echo-affirmative → commands.beta/echo-affirmative
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ function echo_affirmative() (
cat <<-EOF >/dev/stderr
ABOUT:
For each <input>, output 'yes' if affirmative, 'no' if non-affirmative, otherwise note the invalidity to stderr.
Using [is-affirmative] for the validation.

USAGE:
echo-affirmative [...options] [--] ...<input>
Expand Down Expand Up @@ -45,7 +44,7 @@ function echo_affirmative() (
# exit status: 91

EOF
if test "$#" -ne 0; then
if [[ $# -ne 0 ]]; then
echo-error "$@"
fi
return 22 # EINVAL 22 Invalid argument
Expand All @@ -58,17 +57,17 @@ function echo_affirmative() (
function on_input {
local status
eval_capture --statusvar=status -- is-affirmative -- "$1"
if test "$status" -eq 0; then
if [[ $status -eq 0 ]]; then
__print_lines 'yes'
elif test "$status" -eq 1; then
elif [[ $status -eq 1 ]]; then
__print_lines 'no'
else
echo-style --error="[$1] is neither affirmative or non-affirmative" >/dev/stderr
had_invalid_input=yes
fi
}
function on_finish {
if test "$had_invalid_input" = yes; then
if [[ $had_invalid_input == yes ]]; then
return 91 # ENOMSG 91 No message of desired type
fi
}
Expand All @@ -77,6 +76,6 @@ function echo_affirmative() (
)

# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
if [[ $0 == "${BASH_SOURCE[0]}" ]]; then
echo_affirmative "$@"
fi
4 changes: 2 additions & 2 deletions commands.beta/echo-escape-special
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function echo_escape_special() (
# exit status: 0

EOF
if test "$#" -ne 0; then
if [[ $# -ne 0 ]]; then
echo-error "$@"
fi
return 22 # EINVAL 22 Invalid argument
Expand All @@ -42,6 +42,6 @@ function echo_escape_special() (
)

# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
if [[ $0 == "${BASH_SOURCE[0]}" ]]; then
echo_escape_special "$@"
fi
16 changes: 9 additions & 7 deletions commands.beta/echo-exit-affirmative
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env bash

# @should be renamed to eval-then-affirm-status

function echo_exit_affirmative() (
source "$DOROTHY/sources/bash.bash"

Expand Down Expand Up @@ -28,7 +30,7 @@ function echo_exit_affirmative() (
echo-exit-affirmative --fallback=no -- waiter 0 --status=2
outputs: no
EOF
if test "$#" -ne 0; then
if [[ $# -ne 0 ]]; then
echo-error "$@"
fi
return 22 # EINVAL 22 Invalid argument
Expand All @@ -37,7 +39,7 @@ function echo_exit_affirmative() (
# process
local rand="$RANDOM"
local item option_cmd=() option_fallback="$rand"
while test "$#" -ne 0; do
while [[ $# -ne 0 ]]; do
item="$1"
shift
case "$item" in
Expand All @@ -53,7 +55,7 @@ function echo_exit_affirmative() (
done

# check
if test "${#option_cmd[@]}" -eq 0; then
if [[ ${#option_cmd[@]} -eq 0 ]]; then
help "No <command> was provided."
fi

Expand All @@ -62,18 +64,18 @@ function echo_exit_affirmative() (

local cmd_status
eval_capture --statusvar=cmd_status -- "${option_cmd[@]}"
if test "$cmd_status" -eq 0; then
if [[ $cmd_status -eq 0 ]]; then
__print_lines 'yes'
elif test "$cmd_status" -eq 1; then
elif [[ $cmd_status -eq 1 ]]; then
__print_lines 'no'
elif test "$option_fallback" != "$rand"; then
elif [[ $option_fallback != "$rand" ]]; then
__print_lines "$option_fallback"
else
return "$cmd_status"
fi
)

# fire if invoked standalone
if test "$0" = "${BASH_SOURCE[0]}"; then
if [[ $0 == "${BASH_SOURCE[0]}" ]]; then
echo_exit_affirmative "$@"
fi
Loading
Loading