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

scripts/btrfs-balance: Eliminate BASHism #17

Merged
merged 1 commit into from Jan 11, 2023
Merged

scripts/btrfs-balance: Eliminate BASHism #17

merged 1 commit into from Jan 11, 2023

Conversation

Olf0
Copy link
Contributor

@Olf0 Olf0 commented May 29, 2022

AFAIK, the parameter expansion in line 58 of the type "string substitution" (${parameter/pattern/string}) is a BASHism and not supported by POSIX sh / classic Bourne Shell, dash and ash (Almquist shell). At least this is what the corresponding man pages tell.

For more aspects and details, see a9841fe#commitcomment-74846912.

AFAIK, [the parameter expansion in line 58 of the type "string substitution"](a9841fe#diff-491069f1965ccb0506394dca405aa76384f90d722c1e3dd4e227c28e6b002248R58) (`${parameter/pattern/string}`) is a BASHism and not supported by POSIX sh / classic Bourne Shell, dash and ash (Almquist shell).  At least this is what the corresponding man pages tell.
Olf0 referenced this pull request May 29, 2022
Statefs is deprecated and should not be used anymore.

Get battery/charger info from mce via D-Bus instead of using
data under /run/state/namespaces/Battery provided by statefs.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
@llewelld
Copy link
Member

I tested the change in isolation on-device using BusyBox v1.33.1, and both the before and after versions worked perfectly (i.e. returned "on" or "off" depending on the charging state). For the reasons @Olf0 gives, I'd be in favour of accepting the change.

Copy link
Member

@llewelld llewelld left a comment

Choose a reason for hiding this comment

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

I've not tested it in the context of the whole script, but in isolation the change works fine and removes a potential future snag, so LGTM.

@pvuorela pvuorela merged commit 05dcdcd into sailfishos:master Jan 11, 2023
@Olf0 Olf0 deleted the patch-1 branch January 11, 2023 17:22
@Olf0
Copy link
Contributor Author

Olf0 commented Jan 11, 2023

Just for the record: The two variants (before and after this commit) are 100% equivalent, if the Shell used supports the "before this commit" variant. For Busybox's ash this bash extension is not documented to be supported; despite that it seemed to work. Nothing I would rely on, hence this commit.

Thank you for merging.

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

3 participants