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

Remove bash dep from init scripts #98781

Merged
merged 1 commit into from
Feb 22, 2024
Merged

Remove bash dep from init scripts #98781

merged 1 commit into from
Feb 22, 2024

Conversation

am11
Copy link
Member

@am11 am11 commented Feb 21, 2024

upstream changes dotnet/arcade#14500

@am11 am11 marked this pull request as ready for review February 22, 2024 07:35
@ghost
Copy link

ghost commented Feb 22, 2024

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Issue Details

upstream changes dotnet/arcade#14500

Author: am11
Assignees: -
Labels:

area-Infrastructure

Milestone: -

@am11 am11 added the community-contribution Indicates that the PR has been added by a community member label Feb 22, 2024
@ViktorHofer ViktorHofer merged commit d908f00 into dotnet:main Feb 22, 2024
178 of 180 checks passed
illumos_*)
nonPortableRid=openindiana-"$targetArch"
;;
__smartos_major_version=$(echo "$__uname_version" | cut -c9-10)
Copy link
Member

Choose a reason for hiding this comment

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

Is this a typo? Or is the range also 9-10?

Copy link
Member Author

Choose a reason for hiding this comment

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

Bash syntax was 'skip 8 chars and select next two', new syntax is 'cut/select characters 9 and 10'.

VERSION_ID="${VERSION_ID%.*}"
. "${rootfsDir}/etc/os-release"
if [ "${ID}" = "rhel" ] || [ "${ID}" = "rocky" ] || [ "${ID}" = "alpine" ]; then
VERSION_ID="${VERSION_ID%.*}" # Remove the last version digit for these distros
Copy link
Member

Choose a reason for hiding this comment

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

We stopped using it this trimming type of expansion for __solaris_major_version but not here. Is there difference in shell supports?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, ChatGPT thinks this is the way to go, and shellcheck doesn't complain.
Bourne Shell:
image

But good eye! I'll make it consistent later today.

Copy link
Member Author

Choose a reason for hiding this comment

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

ChatGPT's reply:

If your target environments are systems that are 15 years old or newer, you are generally in a safe zone regarding the support for ${variable%pattern} parameter expansion. This feature is part of the POSIX standard, and most Unix-like systems from the last 15 years would have /bin/sh linked to a shell that supports POSIX parameter expansion

so advanced ops like substring extraction ${string:position:length} are bash-specific. So I think we can safely use that parameter expansion syntax for now.

@am11 am11 deleted the patch-28 branch February 22, 2024 11:39
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Infrastructure community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants