Skip to content

Commit 4dcb546

Browse files
Copilotdjeada
andauthored
Fix hook scripts: shebang placement and whitespace removal logic (#28)
* Initial plan * Fix hook scripts: shebang placement and whitespace removal Co-authored-by: djeada <37275728+djeada@users.noreply.github.com> * Add detailed comment explaining trailing whitespace removal pattern Co-authored-by: djeada <37275728+djeada@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: djeada <37275728+djeada@users.noreply.github.com>
1 parent a514d6e commit 4dcb546

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

src/beautify_script.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# hooks/beautify_script.sh
21
#!/usr/bin/env bash
32

43
# Ensure tput has something to work with (avoids set -e abort)
@@ -103,3 +102,4 @@ main() {
103102
}
104103

105104
main "$@"
105+

src/remove_trailing_whitespaces.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ remove_trailing_whitespaces() {
2525
if [[ $line == *[[:space:]] ]]; then
2626
echo "Found trailing whitespaces in line: ${line}"
2727
if [[ $checkonly -eq 0 ]]; then
28-
echo "${line/%[[:space:]]/}" >> "${file}".tmp
28+
# Remove all trailing whitespace using parameter expansion:
29+
# ${line##*[![:space:]]} finds trailing whitespace (everything after last non-space char)
30+
# ${line%...} removes that trailing portion from line
31+
echo "${line%"${line##*[![:space:]]}"}" >> "${file}".tmp
2932
else
3033
status=1
3134
fi

0 commit comments

Comments
 (0)