diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e50771..f1420b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed + +- Standardized spacing in `head` and `tail` commands across scripts and Makefile for consistency (#90). + ## [3.1.2] - 2025-11-11 ### Fixed diff --git a/Makefile b/Makefile index 86ddc0b..42f4ee8 100755 --- a/Makefile +++ b/Makefile @@ -68,9 +68,9 @@ compile: @ # Insert default datapath variable into $(PROG) @ echo -n "Compiling command file ..." @ { \ - head -n1 $(PROG); \ + head -n 1 $(PROG); \ echo "$(DATAPATHVAR)=\"$(SHAREPATH)/$(PROG)\""; \ - tail -n+2 $(PROG); \ + tail -n +2 $(PROG); \ } > $(COMPILEDIR)/$(PROG) @ chmod +x $(COMPILEDIR)/$(PROG) @ echo DONE @@ -84,7 +84,7 @@ compile: echo -n "\"Version "; echo -n $$(cat $(VERFILE)); echo -n "\" "; \ echo; \ } > $(COMPILEDIR)/$(MANFILE) - @ sed 's/`\([^`]\+\)<\([^>]\+\)>`__/\1\n \2/g' $(MANRST) | $(RST2MAN) | tail -n+33 >> $(COMPILEDIR)/$(MANFILE) + @ sed 's/`\([^`]\+\)<\([^>]\+\)>`__/\1\n \2/g' $(MANRST) | $(RST2MAN) | tail -n +33 >> $(COMPILEDIR)/$(MANFILE) @ echo DONE @ # Copy README and MAN rst into COMPILEDIR @@ -144,10 +144,10 @@ distsingle: @ echo -n "Compiling single script ..." @ # Insert content of $(USAGEFILE) and $(VERFILE) into $(PROG) as variables @ { \ - head -n1 $(PROG); \ + head -n 1 $(PROG); \ echo "$(USAGEVAR)=\"$$(cat $(USAGEFILE))\""; \ echo "$(VERSIONVAR)=\"$$(cat $(VERFILE))\""; \ - tail -n+2 $(PROG); \ + tail -n +2 $(PROG); \ } > $(PROGSINGLE) @ chmod +x $(PROGSINGLE) @ echo DONE diff --git a/flow b/flow index 80f059a..9e240f6 100755 --- a/flow +++ b/flow @@ -264,7 +264,7 @@ main() { } top_vertag() { - git tag --list | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -1 | tr -d v + git tag --list | grep -E "^v[0-9]+\.[0-9]+\.[0-9]+$" | sort -V | tail -n 1 | tr -d v } git_merge_nocommit() { @@ -467,7 +467,7 @@ main() { } version_lte() { - [[ "${1}" == "$(echo -e "${1}\n${2}" | sort -V | head -n1)" ]] + [[ "${1}" == "$(echo -e "${1}\n${2}" | sort -V | head -n 1)" ]] } validate_requirements() { @@ -1221,16 +1221,16 @@ main() { flow_usage() { local file head tail - head="$(echo "${USAGE:-}" | head -n1)" - tail="$(echo "${USAGE:-}" | tail -n+2)" + head="$(echo "${USAGE:-}" | head -n 1)" + tail="$(echo "${USAGE:-}" | tail -n +2)" file="${DATAPATH}/${SCRIPT_NAME}.usage" [[ -z "${head}" ]] \ && [[ ! -f "${file}" ]] \ && echo 'Usage is not available in source file.' \ && return [[ -z "${head}" ]] \ - && head="$(head -n1 "${file}")" \ - && tail="$(tail -n+2 "${file}")" + && head="$(head -n 1 "${file}")" \ + && tail="$(tail -n +2 "${file}")" echo "${head}" echo local indent=0 diff --git a/test/test.butt b/test/test.butt index c1cea39..208601e 100755 --- a/test/test.butt +++ b/test/test.butt @@ -37,7 +37,7 @@ function checkInitFiles { assert_equal "$(git show "${1:-main}":VERSION)" "0.0.0" assert_equal "$(git show staging:VERSION)" "0.0.0" assert_equal "$(git show "${1:-main}"-0:VERSION)" "0.0.0" - assert_equal "$(head -n1 CHANGELOG.md)" "# Change Log" + assert_equal "$(head -n 1 CHANGELOG.md)" "# Change Log" } function grep_log { @@ -420,8 +420,8 @@ start "merge feature" assert_contains "${log}" "Update changelog" assert_contains "${loglines[0]}" "(HEAD -> dev) Merge branch 'myfeature' into dev" assert_equal "$(git show-ref | grep /refs/heads/feature-myfeature)" "" - assert_equal "$(git show dev:CHANGELOG.md | head -9 | tail -1)" "### Added" - assert_equal "$(git show dev:CHANGELOG.md | head -11 | tail -1)" "- feature1" + assert_equal "$(git show dev:CHANGELOG.md | head -n 9 | tail -n 1)" "### Added" + assert_equal "$(git show dev:CHANGELOG.md | head -n 11 | tail -n 1)" "- feature1" assert_equal "$(gsp)" "" debug "flow -n" assert_equal "${status}" 0 @@ -484,9 +484,9 @@ start "create staging" assert_equal "${status}" 0 assert_equal "$(git show dev:VERSION)" "0.2.0" assert_equal "$(git show staging:VERSION)" "0.1.0" - assert_equal "$(git show dev:CHANGELOG.md | head -7 | tail -1)" "## [Unreleased]" - assert_contains "$(git show dev:CHANGELOG.md | head -9 | tail -1)" "## [0.1.0-rc.1] - " - assert_contains "$(git show staging:CHANGELOG.md | head -7 | tail -1)" "## [0.1.0-rc.1] - " + assert_equal "$(git show dev:CHANGELOG.md | head -n 7 | tail -n 1)" "## [Unreleased]" + assert_contains "$(git show dev:CHANGELOG.md | head -n 9 | tail -n 1)" "## [0.1.0-rc.1] - " + assert_contains "$(git show staging:CHANGELOG.md | head -n 7 | tail -n 1)" "## [0.1.0-rc.1] - " assert_contains "$(git show-ref)" "refs/heads/staging" assert_equal "$(gsp)" "" debug "flow -n" @@ -503,11 +503,11 @@ start "create rc2" assert_equal "${status}" 0 assert_equal "$(git show dev:VERSION)" "0.2.0" assert_equal "$(git show staging:VERSION)" "0.1.0" - assert_equal "$(git show dev:CHANGELOG.md | head -7 | tail -1)" "## [Unreleased]" - assert_contains "$(git show dev:CHANGELOG.md | head -9 | tail -1)" "## [0.1.0-rc.2] - " - assert_contains "$(git show dev:CHANGELOG.md | head -11 | tail -1)" "## [0.1.0-rc.1] - " - assert_contains "$(git show staging:CHANGELOG.md | head -7 | tail -1)" "## [0.1.0-rc.2] - " - assert_contains "$(git show staging:CHANGELOG.md | head -9 | tail -1)" "## [0.1.0-rc.1] - " + assert_equal "$(git show dev:CHANGELOG.md | head -n 7 | tail -n 1)" "## [Unreleased]" + assert_contains "$(git show dev:CHANGELOG.md | head -n 9 | tail -n 1)" "## [0.1.0-rc.2] - " + assert_contains "$(git show dev:CHANGELOG.md | head -n 11 | tail -n 1)" "## [0.1.0-rc.1] - " + assert_contains "$(git show staging:CHANGELOG.md | head -n 7 | tail -n 1)" "## [0.1.0-rc.2] - " + assert_contains "$(git show staging:CHANGELOG.md | head -n 9 | tail -n 1)" "## [0.1.0-rc.1] - " assert_contains "$(git show-ref)" "refs/heads/staging" assert_equal "$(gsp)" "" debug "flow -n" @@ -525,13 +525,13 @@ start "release rc2" assert_equal "${status}" 0 assert_equal "$(git show dev:VERSION)" "0.2.0" assert_equal "$(git show staging:VERSION)" "0.1.0" - assert_equal "$(git show dev:CHANGELOG.md | head -7 | tail -1)" "## [Unreleased]" - assert_contains "$(git show dev:CHANGELOG.md | head -9 | tail -1)" "## [0.1.0] - " - assert_contains "$(git show dev:CHANGELOG.md | head -13 | tail -1)" "## [0.1.0-rc.2] - " - assert_contains "$(git show dev:CHANGELOG.md | head -15 | tail -1)" "## [0.1.0-rc.1] - " - assert_contains "$(git show main:CHANGELOG.md | head -7 | tail -1)" "## [0.1.0] - " - assert_contains "$(git show main:CHANGELOG.md | head -11 | tail -1)" "## [0.1.0-rc.2] - " - assert_contains "$(git show main:CHANGELOG.md | head -13 | tail -1)" "## [0.1.0-rc.1] - " + assert_equal "$(git show dev:CHANGELOG.md | head -n 7 | tail -n 1)" "## [Unreleased]" + assert_contains "$(git show dev:CHANGELOG.md | head -n 9 | tail -n 1)" "## [0.1.0] - " + assert_contains "$(git show dev:CHANGELOG.md | head -n 13 | tail -n 1)" "## [0.1.0-rc.2] - " + assert_contains "$(git show dev:CHANGELOG.md | head -n 15 | tail -n 1)" "## [0.1.0-rc.1] - " + assert_contains "$(git show main:CHANGELOG.md | head -n 7 | tail -n 1)" "## [0.1.0] - " + assert_contains "$(git show main:CHANGELOG.md | head -n 11 | tail -n 1)" "## [0.1.0-rc.2] - " + assert_contains "$(git show main:CHANGELOG.md | head -n 13 | tail -n 1)" "## [0.1.0-rc.1] - " assert_contains "$(git show-ref)" "refs/heads/dev" assert_equal "$(gsp)" "" debug "flow -n"