Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
449e09e
Standardize exit and return codes using sysexits.h constants
Kamilcuk May 2, 2026
a4c36e7
update freebsd setup and add tests and add qemuperfbash
Kamilcuk Jun 4, 2026
3913302
tests: fix freebsd compatibility
Kamilcuk Jun 4, 2026
9544878
add L_fuzzy
Kamilcuk Jun 4, 2026
d367a01
speed up L_pipe, add L_mktemp
Kamilcuk Jun 4, 2026
e8f8393
L_finally: add -f option, hardcode traps, do not register realtime si…
Kamilcuk Jun 4, 2026
36e0814
add L_with_set and L_shopt, other cosmetics
Kamilcuk Jun 4, 2026
2ffb365
L_sort_bash: optimize implementation and fix infinite loop on duplicates
Kamilcuk Jun 5, 2026
19c7fc9
rename L_*v convnetion into L_RET
Kamilcuk Jun 5, 2026
1c2e1b7
rename assignment functions with *_into suffix from *_to
Kamilcuk Jun 5, 2026
1dbfb51
L_timeout renames work to use duration or usec explicitly, use L_with…
Kamilcuk Jun 5, 2026
915c18f
tests: disable SIGHUP tests in _L_test_finally due to environment res…
Kamilcuk Jun 6, 2026
4a2b6cf
fix tests, rename L_with_set to L_set
Kamilcuk Jun 6, 2026
ff162d1
docs: pin docs requirements, move to single docs job
Kamilcuk Jun 6, 2026
996195d
fix shellcheck, improve filename naming in L_mktemp and L_pipe
Kamilcuk Jun 6, 2026
3ffcdfb
fix _L_test_wait_err to really test on inexisting pid
Kamilcuk Jun 7, 2026
05b4164
L_func_comment: fix missing local
Kamilcuk Jun 7, 2026
6d94718
fix, cosmetics, print error location on github actions
Kamilcuk Jun 7, 2026
03a9d24
tests: add pstree for freebsd and add check for tests
Kamilcuk Jun 7, 2026
963ab84
tests fixes
Kamilcuk Jun 7, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 35 additions & 57 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,46 @@ jobs:
python-version: '3.x'
- run: make test_pip

build_pages:
test_freebsd:
runs-on: ubuntu-latest
if: github.event.action != 'closed'
timeout-minutes: 3
timeout-minutes: 10
steps:
- uses: actions/checkout@v6
- uses: vmactions/freebsd-vm@v1
with:
prepare: |
pkg install -y jq bash pstree
run: |
./tests/citest.sh

docs:
runs-on: ubuntu-latest
if: github.event.action != 'closed'
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v6
- uses: astral-sh/setup-uv@v7
- run: make docs_build
- uses: actions/upload-artifact@v4
- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
branch: gh-pages
clean-exclude: pr-preview/
force: false
- name: Deploy preview
if: github.event_name == 'pull_request'
uses: rossjrw/pr-preview-action@v1
with:
name: site-docs
path: site
source-dir: site
preview-branch: gh-pages
umbrella-dir: pr-preview
action: deploy

build_basher:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -123,7 +151,7 @@ jobs:
deploy_docker:
runs-on: ubuntu-latest
timeout-minutes: 3
needs: [test, test_ubuntu, shellcheck, build_pages, build_basher, test_pip]
needs: [test, test_ubuntu, shellcheck, docs, build_basher, test_pip, test_freebsd]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: read
Expand Down Expand Up @@ -164,56 +192,6 @@ jobs:
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true

deploy_pages:
runs-on: ubuntu-latest
timeout-minutes: 3
needs: [build_pages]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
permissions:
contents: write
environment:
name: github-pages
url: https://kamilcuk.github.io/L_lib
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: site-docs
path: site
- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
branch: gh-pages
clean-exclude: pr-preview/
force: false

preview_pages:
runs-on: ubuntu-latest
timeout-minutes: 3
needs: [build_pages]
if: github.event_name == 'pull_request' && github.event.action != 'closed'
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: site-docs
path: site
- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
with:
source-dir: site
preview-branch: gh-pages
umbrella-dir: pr-preview
action: deploy

preview_cleanup:
runs-on: ubuntu-latest
timeout-minutes: 3
Expand All @@ -233,7 +211,7 @@ jobs:

pypi-publish:
name: Upload release to PyPI
needs: [test, test_ubuntu, shellcheck, test_pip]
needs: [test, test_ubuntu, shellcheck, test_pip, test_freebsd]
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
timeout-minutes: 5
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ __pycache__/
dist/
TODO.md

tmp
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ The project adheres to strict conventions to maintain consistency and readabilit
* **Result Storage:** Functions designed to return values use the `-v <var>` option to store their output in the specified variable, mirroring `printf -v`. If `-v` is not provided, results are typically printed to standard output.
* **Return Codes:**
* `0`: Success.
* `2`: Usage errors (e.g., incorrect arguments).
* `124`: Timeout.
* `64` (L_EX_USAGE): Usage errors (e.g., incorrect arguments).
* `124` ($L_EX_TIMEOUT): Timeout.
* **Shell Options:** Scripts and the library itself operate with `set -euo pipefail` to ensure robust error handling and predictable behavior.
* **Testing Practices:** Unit tests are organized into functions prefixed with `_L_test_` within `tests/test.sh` and are executed by `L_unittest_main`. New tests should be added to separate files in the `tests/` directory and sourced from `tests/test.sh`. Each test file should contain multiple tests for a reasonable section or group of functions.

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ COPY bin/L_lib.sh /bin/L_lib.sh
RUN /bin/L_lib.sh --help

FROM docker.io/library/bash:${VERSION} AS tester
RUN apk add --no-cache jq
RUN apk add --no-cache jq psmisc

FROM tester AS test
USER nobody:nogroup
Expand Down Expand Up @@ -47,7 +47,7 @@ RUN basher list -v
RUN L_lib.sh --help

FROM docker.io/library/bash:${VERSION} AS perfbash
RUN apk add --no-cache perf bubblewrap bc coreutils util-linux
RUN apk add --no-cache perf bubblewrap bc coreutils util-linux psmisc
COPY . /app/
WORKDIR /app
CMD ["./scripts/perfbash"]
12 changes: 4 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test_parallel:
if ! $(MAKE) -O -j $(NPROC) test > >(tee build/output >&2) 2>&1; then \
grep -B500 '^make\[.*\]:.*Makefile.*\] Error' build/output; \
grep '^make\[.*\]:.*Makefile.*\] Error' build/output; \
exit 2; \
exit 64; \
fi
test_parallel2:
@mkdir -vp build
Expand Down Expand Up @@ -140,19 +140,15 @@ runall: $(addprefix run-, $(BASHES))

.PHONY: docs_build docs_serve
_docs:
uvx --with-requirements=./docs/requirements.txt mkdocs $(WHAT)
uv run --group docs mkdocs $(WHAT)
docs_build: WHAT = build
docs_build: _docs
docs_serve: WHAT = serve --livereload --dirtyreload
docs_serve: _docs
docs_serve2:
uvx --with-requirements=./docs/requirements.txt --with-editable=../mkdocstrings-sh/ mkdocs serve --livereload --dirtyreload
uv run --group docs mkdocs serve --livereload --dirtyreload
docs_docker:
$(DOCKER) build --target doc --output type=local,dest=./public .

K ?= 2
llm:
,llm --no-hide -k $(K) gemini --model gemini-2.5-pro -r

llm2:
GOOGLE_GEMINI_BASE_URL=http://localhost:8990/gemini ,llm --no-hide -k $(K) gemini --model my -r
,llm --podman -H gemini
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ Below is a selection of the library's features. The library contains much more.
[`$L_HAS_WAIT_N`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_HAS_WAIT_N)
- Waiting on multiple PIDs with a timeout ignoring signals and collecting all exit codes
[`L_wait`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_wait)
- Standard exit codes based on `sysexits.h`
[`$L_EX_OK`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_EX_OK)
[`$L_EX_USAGE`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_EX_USAGE)
[`$L_EX_TIMEOUT`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_EX_TIMEOUT)
- Simplify storing exit status of a command into a variable
[`L_exit_to`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_exit_to)
[`L_exit_to_10`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_exit_to_10)
[`L_exit_into`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_exit_into)
[`L_exit_into_10`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_exit_into_10)
- Help with path operations, with `PATH` or `PYTHONPATH` manipulation
[`L_path_stem`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_path_stem)
[`L_dir_is_empty`](https://kamilcuk.github.io/L_lib/section/all/#L_lib.sh--L_dir_is_empty)
Expand Down Expand Up @@ -162,8 +166,8 @@ Contributions are welcome! You can run the tests locally with `make test` or che
- The option `-v <var>` is used to store the result in a variable instead of printing it.
- This follows the convention of `printf -v <var>`.
- Without the `-v` option, the function outputs the elements on lines to standard output.
- Associated function with `_v` suffix store the result in a hardcoded scratch variable `L_v`.
- Return 2 on usage error, return 124 on timeout.
- Associated function with `_vL_RET` suffix store the result in a hardcoded scratch variable `L_RET`.
- Return 64 ($L_EX_USAGE) on usage error, return 124 ($L_EX_TIMEOUT) on timeout.

# License

Expand Down
Loading
Loading