Skip to contentSkip to conversation

prepare-kernel.sh: expand tilde in --outpatch path parameter

PATCH Applied Haiyang He 3 participants 4 messages Apr 14, 2025 – Apr 16, 2025

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore

Haiyang He

author
#0 lore raw

PATCH 1/1 prepare-kernel.sh: expand tilde in --outpatch path parameter

Ensure shell expands tilde (~) in the --outpatch parameter path the same way as --linux and --dovetail parameters. This fixes "cd: can't cd to ~" errors when using home directory shortcuts in output path.

The issue occurred because the ~ character in paths was not expanded before directory operations.

$ ./scripts/prepare-kernel.sh \
--linux=~/xenomai/linux-dovetail \
--arch=arm64 \
--outpatch=~/xenomai.patch
./scripts/prepare-kernel.sh: 1: cd: can't cd to ~
---
 scripts/prepare-kernel.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/prepare-kernel.sh +1 -0
index ecc830fd2..e15c1fe6e 100755
@@ -139,6 +139,7 @@ while test $# -gt 0; do
 		;;
 	--outpatch=*)
 		output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+		output_patch=`eval "echo $output_patch"`
 		;;
 	--filterkvers=*)
 		echo "$me: warning: --filterkvers= is deprecated and now a no-op" >&2
Signature · 1 line
2.34.1
#1 lore raw
Quoted 24 lines · Haiyang He

Ensure shell expands tilde (~) in the --outpatch parameter path the same way as --linux and --dovetail parameters. This fixes "cd: can't cd to ~" errors when using home directory shortcuts in output path.

The issue occurred because the ~ character in paths was not expanded before directory operations.

$ ./scripts/prepare-kernel.sh \
--linux=~/xenomai/linux-dovetail \
--arch=arm64 \
--outpatch=~/xenomai.patch
./scripts/prepare-kernel.sh: 1: cd: can't cd to ~
---
 scripts/prepare-kernel.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/prepare-kernel.sh +0 -0
index ecc830fd2..e15c1fe6e 100755

scripts/prepare-kernel.sh while test $# -gt 0; do · line 142

Quoted 4 lines
scripts/prepare-kernel.sh +1 -0
@@ -139,6 +139,7 @@ while test $# -gt 0; do
 		;;
 	--outpatch=*)
 		output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+		output_patch=`eval "echo $output_patch"`

Something like "realpath" should do it (instead of eval), no?

Btw: AFAIR command substitutions should be done with the $() syntax nowadays (instead of ``).

Quoted 5 lines
scripts/prepare-kernel.sh +0 -0
 		;;
 	--filterkvers=*)
 		echo "$me: warning: --filterkvers= is deprecated and now a no-op" >&2
Signature · 1 line
2.34.1
author
#2 lore raw
Quoted 32 lines · Florian Bezdeka
Quoted 24 lines · Haiyang He

Ensure shell expands tilde (~) in the --outpatch parameter path the same way as --linux and --dovetail parameters. This fixes "cd: can't cd to ~" errors when using home directory shortcuts in output path.

The issue occurred because the ~ character in paths was not expanded before directory operations.

$ ./scripts/prepare-kernel.sh \
--linux=~/xenomai/linux-dovetail \
--arch=arm64 \
--outpatch=~/xenomai.patch
./scripts/prepare-kernel.sh: 1: cd: can't cd to ~
---
 scripts/prepare-kernel.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/prepare-kernel.sh +0 -0
index ecc830fd2..e15c1fe6e 100755

scripts/prepare-kernel.sh while test $# -gt 0; do · line 142

Quoted 4 lines
scripts/prepare-kernel.sh +1 -0
@@ -139,6 +139,7 @@ while test $# -gt 0; do
 		;;
 	--outpatch=*)
 		output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+		output_patch=`eval "echo $output_patch"`

Something like "realpath" should do it (instead of eval), no?

Quoted 3 lines

Btw: AFAIR command substitutions should be done with the $() syntax nowadays (instead of ``).

Make sense, and this works:

output_patch=$(eval "realpath $output_patch")

I will resend patch v2.

Quoted 6 lines
Quoted 5 lines
scripts/prepare-kernel.sh +0 -0
 		;;
 	--filterkvers=*)
 		echo "$me: warning: --filterkvers= is deprecated and now a no-op" >&2
Signature · 1 line
2.34.1
Applied
#3 lore raw
In reply to Haiyang He
Quoted 24 lines · Haiyang He

Ensure shell expands tilde (~) in the --outpatch parameter path the same way as --linux and --dovetail parameters. This fixes "cd: can't cd to ~" errors when using home directory shortcuts in output path.

The issue occurred because the ~ character in paths was not expanded before directory operations.

$ ./scripts/prepare-kernel.sh \
--linux=~/xenomai/linux-dovetail \
--arch=arm64 \
--outpatch=~/xenomai.patch
./scripts/prepare-kernel.sh: 1: cd: can't cd to ~
---
 scripts/prepare-kernel.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/prepare-kernel.sh +0 -0
index ecc830fd2..e15c1fe6e 100755

scripts/prepare-kernel.sh while test $# -gt 0; do · line 145

Quoted 7 lines
scripts/prepare-kernel.sh +1 -0
@@ -139,6 +139,7 @@ while test $# -gt 0; do
 		;;
 	--outpatch=*)
 		output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+		output_patch=`eval "echo $output_patch"`
 		;;
 	--filterkvers=*)
 		echo "$me: warning: --filterkvers= is deprecated and now a no-op" >&2

Thanks, applied.

Jan

Signature · 2 lines
Siemens AG, Foundational Technologies
Linux Expert Center