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

Use the bash native capitalizing method if available, and fallback to other functions #620

Merged
merged 4 commits into from
Nov 28, 2024

Conversation

lens0021
Copy link
Contributor

@lens0021 lens0021 commented Nov 26, 2024

  1. Since bash 4.01, There is a native method to capitalize a variable. So use it.
  2. The previous method, using \U in sed is not supported BusyBox sed, maybe. (I've searched on https://github.com/brgl/busybox/blob/master/editors/sed.c) So add a check to GNU sed. (This fixes one test of three failed busybox tests [BUG] Broken BusyBox compatibility #617)
  3. If the all above options are not available, use the text functions to implement capitalizing.

I've run this for several envs and the result:
image
(You can see the test workflow at lens0021#1)

Footnotes

  1. docker run --rm bash:4.0 bash -c 'foo="aaa"; echo "${foo^}"' -> Aaa, docker run --rm bash:3.2 bash -c 'foo="aaa"; echo "${foo^}"' -> bash: ${foo^}: bad substitution

@lens0021 lens0021 changed the title Use the bash native capitalizing method if available, or fallback to other functions Use the bash native capitalizing method if available, and fallback to other functions Nov 26, 2024
@Mte90 Mte90 requested review from hdwalters and Ph0enixKM November 26, 2024 15:03
src/std/text.ab Show resolved Hide resolved
src/std/text.ab Show resolved Hide resolved
Co-authored-by: hdwalters <[email protected]>
@Mte90 Mte90 merged commit 05caef9 into amber-lang:master Nov 28, 2024
1 check passed
@lens0021 lens0021 deleted the fallback-capitalize branch November 28, 2024 11:30
lens0021 added a commit to lens0021/amber that referenced this pull request Dec 12, 2024
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.

3 participants