Skip to contentSkip to conversation

mingw_sdk_handle_symlink.bbclass: avoid using non-posix -d option for read

PATCH In review [email protected] 2 participants 3 messages Jan 16 – Jan 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mingw_sdk_handle_symlink.bbclass: avoid using non-posix -d option for read

From: Chen Qi <[email protected]>

The '-d' option for read is bash specific extension. We need to avoid using it.

---
 classes/mingw_sdk_handle_symlink.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
classes/mingw_sdk_handle_symlink.bbclass +1 -1
index 2f6dbe6..e158d14 100644
@@ -3,7 +3,7 @@ WINSDK_NO_SYMLINK ?= "0"
 archive_sdk:prepend:sdkmingw32 () {
 	if [ "${WINSDK_NO_SYMLINK}" = "1" ]; then
 		for parse_type in "file" "directory"; do
-			find "${SDK_OUTPUT}/${SDKPATH}" -type l -print0 | while IFS= read -r -d '' symlink; do
+			find "${SDK_OUTPUT}/${SDKPATH}" -type l -print | while read -r symlink; do
 				target=$(readlink -f "$symlink" || echo "NOTVALID")
 				if [ "$target" = "NOTVALID" ]; then
 					continue
Signature · 1 line
2.43.0
#1 lore raw
Quoted 16 lines · On Thu, Jan 15, 2026 at 10:05 PM <[email protected]> wrote:

From: Chen Qi <[email protected]>

The '-d' option for read is bash specific extension. We need to avoid using it.

---
 classes/mingw_sdk_handle_symlink.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
classes/mingw_sdk_handle_symlink.bbclass +0 -0
index 2f6dbe6..e158d14 100644

classes/mingw_sdk_handle_symlink.bbclass WINSDK_NO_SYMLINK ?= "0" · line 6

Quoted 5 lines
classes/mingw_sdk_handle_symlink.bbclass +1 -1
@@ -3,7 +3,7 @@ WINSDK_NO_SYMLINK ?= "0"
 archive_sdk:prepend:sdkmingw32 () {
        if [ "${WINSDK_NO_SYMLINK}" = "1" ]; then
                for parse_type in "file" "directory"; do
-                       find "${SDK_OUTPUT}/${SDKPATH}" -type l -print0 | while IFS= read -r -d '' symlink; do
+                       find "${SDK_OUTPUT}/${SDKPATH}" -type l -print | while read -r symlink; do

This would now break on file names with spaces in them; As much as I would like to say "don't do that", is there some we we can preserve the behavior of using -print0 to allow that to keep working?

Quoted 6 lines
classes/mingw_sdk_handle_symlink.bbclass +0 -1
                                target=$(readlink -f "$symlink" || echo "NOTVALID")
                                if [ "$target" = "NOTVALID" ]; then
                                        continue
--

2.43.0

author
#2 lore raw

Hi Joshua,

I had the same concern with you, so I used '-print0' without doing more test. My instinct was that space is used as the separator by default. But when I fixed this '-d' issue, I tested it. The 'read' command can handle the space by default. It actually uses newline as the separator by default.

Below is an example:

$ find .
.
./dir_without_space
./dir_without_space/file2 with space
./dir_without_space/file2_without_space
./dir with space
./dir with space/file with space
./dir with space/file_without_space
$ find . | while read -r var; do echo "var: $var"; done
var: .
var: ./dir_without_space
var: ./dir_without_space/file2 with space
var: ./dir_without_space/file2_without_space
var: ./dir with space
var: ./dir with space/file with space
var: ./dir with space/file_without_space

Regards,
Qi

-----Original Message-----
From: Joshua Watt <[email protected]>
Sent: Saturday, January 17, 2026 12:30 AM
To: Chen, Qi <[email protected]>
Cc: [email protected]
Subject: Re: [meta-mingw][PATCH] mingw_sdk_handle_symlink.bbclass: avoid using non-posix -d option for read

Quoted 17 lines · On Thu, Jan 15, 2026 at 10:05 PM <[email protected]> wrote:

From: Chen Qi <[email protected]>

The '-d' option for read is bash specific extension. We need to avoid using it.

---
 classes/mingw_sdk_handle_symlink.bbclass | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
classes/mingw_sdk_handle_symlink.bbclass +0 -0
index 2f6dbe6..e158d14 100644

classes/mingw_sdk_handle_symlink.bbclass WINSDK_NO_SYMLINK ?= "0" · line 7

Quoted 6 lines
classes/mingw_sdk_handle_symlink.bbclass +2 -1
@@ -3,7 +3,7 @@ WINSDK_NO_SYMLINK ?= "0"
 archive_sdk:prepend:sdkmingw32 () {
        if [ "${WINSDK_NO_SYMLINK}" = "1" ]; then
                for parse_type in "file" "directory"; do
-                       find "${SDK_OUTPUT}/${SDKPATH}" -type l -print0 | while IFS= read -r -d '' symlink; do
+                       find "${SDK_OUTPUT}/${SDKPATH}" -type l -print 
+ | while read -r symlink; do

This would now break on file names with spaces in them; As much as I would like to say "don't do that", is there some we we can preserve the behavior of using -print0 to allow that to keep working?

Quoted 6 lines
classes/mingw_sdk_handle_symlink.bbclass +0 -1
                                target=$(readlink -f "$symlink" || echo "NOTVALID")
                                if [ "$target" = "NOTVALID" ]; then
                                        continue
--

2.43.0