fix(brief): avoid bash 3.2 parse error from apostrophe in heredoc#132
Open
RevazBakuradze wants to merge 1 commit into
Open
fix(brief): avoid bash 3.2 parse error from apostrophe in heredoc#132RevazBakuradze wants to merge 1 commit into
RevazBakuradze wants to merge 1 commit into
Conversation
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
bin/fm-brief.shfails to parse under thebashthat ships with macOS (GNU bash 3.2.57, still the default/bin/bash). The script's shebang is#!/usr/bin/env bash, so on a stock macOS machine it runs under 3.2 and dies before doing anything:The cause is a bash 3.2 parser bug: a lone single quote (apostrophe) inside a here-doc that is nested in a command substitution (
VAR=$(cat <<EOF ... EOF)) is mis-parsed as the start of a single-quoted string that never closes. Line 211, inside theno-mistakesDOD=$(cat <<EOF ...)block, containsno-mistakes', which trips it. Bash 4+ parses the same construct correctly, so this only affects users on the stock macOS bash.Minimal repro:
Fix
Rephrase that one line to remove the lone apostrophe (no escaping, keeps it readable):
Follow no-mistakes' own guidance for the mechanics:->Follow the no-mistakes guidance for the mechanics:One line changed; no behavior change. It is the only lone apostrophe inside any of the script's
$(cat <<EOF ...)blocks.Verification
bash -n bin/fm-brief.sh-> 2 errors (under bash 3.2.57).bash -n bin/fm-brief.sh-> clean (exit 0), and scaffolding still produces valid briefs.