Skip to contentSkip to conversation

pkgconf: pkg-config.in: double quote $@

PATCH New Gaël PORTAY 3 participants 5 messages Feb 22, 2018 – Mar 30, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 pkgconf: pkg-config.in: double quote $@

The shell expands "$@" as "$1" "$2" "$3"... while it expands $@ as $1 $2 $3. With the second form, we loses spaces in positional parameters.

As example, the following call

        pkg-config --cflags "one two" three

is wrapped as

        pkgconf --cflags one two three

while we are expecting

        pkgconf --cflags "one two" three

"$@" is really useful when writing wrappers. It passes the positional arguments *as* they are given.

Double quote $@ to prevent from splitting elements.

---

Changes since v1:
- improve commit message.

 package/pkgconf/pkg-config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkgconf/pkg-config.in +1 -1
index b9ce0935cc..9387931ff2 100644
@@ -2,4 +2,4 @@
 PKGCONFDIR=$(dirname $0)
 DEFAULT_PKG_CONFIG_LIBDIR=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/lib/pkgconfig:${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/share/pkgconfig
 DEFAULT_PKG_CONFIG_SYSROOT_DIR=${PKGCONFDIR}/../@STAGING_SUBDIR@
-PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-${DEFAULT_PKG_CONFIG_LIBDIR}} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-${DEFAULT_PKG_CONFIG_SYSROOT_DIR}} ${PKGCONFDIR}/pkgconf @STATIC@ $@
+PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-${DEFAULT_PKG_CONFIG_LIBDIR}} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-${DEFAULT_PKG_CONFIG_SYSROOT_DIR}} ${PKGCONFDIR}/pkgconf @STATIC@ "$@"
Signature · 1 line
2.16.1
#1 lore raw

PATCH v2 2/2 pkgconf: pkg-config.in: exec pkgconf

Replace the shell script with pkgconf without creating a new process.

---
No changes since v1

 package/pkgconf/pkg-config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/pkgconf/pkg-config.in +1 -1
index 9387931ff2..99c0add8fb 100644
@@ -2,4 +2,4 @@
 PKGCONFDIR=$(dirname $0)
 DEFAULT_PKG_CONFIG_LIBDIR=${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/lib/pkgconfig:${PKGCONFDIR}/../@STAGING_SUBDIR@/usr/share/pkgconfig
 DEFAULT_PKG_CONFIG_SYSROOT_DIR=${PKGCONFDIR}/../@STAGING_SUBDIR@
-PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-${DEFAULT_PKG_CONFIG_LIBDIR}} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-${DEFAULT_PKG_CONFIG_SYSROOT_DIR}} ${PKGCONFDIR}/pkgconf @STATIC@ "$@"
+PKG_CONFIG_LIBDIR=${PKG_CONFIG_LIBDIR:-${DEFAULT_PKG_CONFIG_LIBDIR}} PKG_CONFIG_SYSROOT_DIR=${PKG_CONFIG_SYSROOT_DIR:-${DEFAULT_PKG_CONFIG_SYSROOT_DIR}} exec ${PKGCONFDIR}/pkgconf @STATIC@ "$@"
Signature · 1 line
2.16.1
#2 lore raw

PATCH v2 2/2 pkgconf: pkg-config.in: exec pkgconf

Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Ga?l" == Ga?l PORTAY <[email protected]> writes:

Replace the shell script with pkgconf without creating a new process.

---
No changes since v1

Committed to 2018.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#3 lore raw

PATCH v2 1/2 pkgconf: pkg-config.in: double quote $@

In reply to Gaël PORTAY

Hello,

Quoted 15 lines · Ga?l PORTAY

The shell expands "$@" as "$1" "$2" "$3"... while it expands $@ as $1 $2 $3. With the second form, we loses spaces in positional parameters.

As example, the following call

        pkg-config --cflags "one two" three

is wrapped as

        pkgconf --cflags one two three

while we are expecting

        pkgconf --cflags "one two" three
Quoted 7 lines

"$@" is really useful when writing wrappers. It passes the positional arguments *as* they are given.

Double quote $@ to prevent from splitting elements.

---

Both patches applied to next. Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 1/2 pkgconf: pkg-config.in: double quote $@

In reply to Gaël PORTAY
Quoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Ga?l" == Ga?l PORTAY <[email protected]> writes:

The shell expands "$@" as "$1" "$2" "$3"... while it expands $@ as $1 $2 $3. With the second form, we loses spaces in positional parameters.

As example, the following call

        pkg-config --cflags "one two" three

is wrapped as

        pkgconf --cflags one two three

while we are expecting

Quoted 8 lines
        pkgconf --cflags "one two" three

"$@" is really useful when writing wrappers. It passes the positional arguments *as* they are given.

Double quote $@ to prevent from splitting elements.

Committed to 2018.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard