Skip to content

rewrite wl-present in posix compliant shell#78

Draft
natthias wants to merge 1 commit into
Ferdi265:mainfrom
natthias:posix
Draft

rewrite wl-present in posix compliant shell#78
natthias wants to merge 1 commit into
Ferdi265:mainfrom
natthias:posix

Conversation

@natthias

Copy link
Copy Markdown

Not sure if this is of interest, but this rewrites scripts/wl-present in posix shell, as nothing in the script particularly required any bashisms. I tested it both with and without pipectl installed and this seems to work just like it did before.

I accidentally left formatting on in my editor, so I ran shfmt. If this pr is of interest, I'll revert the formatting changes and undraft this.

@Ferdi265

Copy link
Copy Markdown
Owner

IMO the posix-compliant version is slightly harder to read, especially around the uses of expr.

If there is a strong reason to not depend on bash then I might think about merging this, but for now I tend more towards staying in bash-land, as I understand bash much better than the details of how different shells implement POSIX-compliant mode, and whether that will work on all shells people could have installed as /bin/sh (e.g. bash, dash, busybox sh (not fully POSIX AFAIR), etc...).

@natthias

natthias commented May 8, 2026

Copy link
Copy Markdown
Author

I agree that particularly the expr stuff is a bit unclear.

The primary benefit I saw was that the script wasn't that difficult to rewrite the script in posix compliant shell. However, bringing up busybox does raise a valid concern: the expr invocation didn't even work on busybox expr... Alternatively a case statement can be used be that starts making things even more explicit:

is_cli_argument() {
case  $1 in
-*) true;;
*) false;
esac
}

Which should work in any shell, but I am unsure how I feel about it

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