* [ptxdist] [PATCH] rootfs: Fix handling of empty variables
@ 2021-02-02 14:58 Sascha Hauer
2021-02-03 7:10 ` Michael Olbrich
0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2021-02-02 14:58 UTC (permalink / raw)
To: ptxdist
$(PTXCONF_PROJECT_VENDOR) and $(PTXCONF_ROOTFS_ETC_HOSTNAME) can be
empty variables in which case bash answers with:
/bin/bash: command substitution: line 0: syntax error near unexpected token `newline'
/bin/bash: command substitution: line 0: `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< '
Fix this warning by putting the variables into quotation marks to make
the empty string explicit.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
rules/rootfs.make | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/rules/rootfs.make b/rules/rootfs.make
index 419ca001e..627d33463 100644
--- a/rules/rootfs.make
+++ b/rules/rootfs.make
@@ -217,11 +217,11 @@ ifdef PTXCONF_ROOTFS_ISSUE
$(call remove_quotes,$(PTXCONF_ROOTFS_ETC_HOSTNAME)))
@$(call install_replace_figlet, rootfs, /etc/issue, \
@FIGLET:VENDOR@, \
- `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_PROJECT_VENDOR)`, \
+ `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< "$(PTXCONF_PROJECT_VENDOR)"`, \
etcissue)
@$(call install_replace_figlet, rootfs, /etc/issue, \
@FIGLET:HOSTNAME@, \
- `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_ROOTFS_ETC_HOSTNAME)`, \
+ `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< "$(PTXCONF_ROOTFS_ETC_HOSTNAME)"`, \
etcissue)
endif
--
2.20.1
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ptxdist] [PATCH] rootfs: Fix handling of empty variables
2021-02-02 14:58 [ptxdist] [PATCH] rootfs: Fix handling of empty variables Sascha Hauer
@ 2021-02-03 7:10 ` Michael Olbrich
2021-02-03 7:23 ` Sascha Hauer
0 siblings, 1 reply; 4+ messages in thread
From: Michael Olbrich @ 2021-02-03 7:10 UTC (permalink / raw)
To: ptxdist
On Tue, Feb 02, 2021 at 03:58:36PM +0100, Sascha Hauer wrote:
> $(PTXCONF_PROJECT_VENDOR) and $(PTXCONF_ROOTFS_ETC_HOSTNAME) can be
> empty variables in which case bash answers with:
>
> /bin/bash: command substitution: line 0: syntax error near unexpected token `newline'
> /bin/bash: command substitution: line 0: `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< '
This is strange. Why are these variables empty? They are strings in
kconfig. The resulting make variables should include the quotes, so they
should never be empty.
Michael
> Fix this warning by putting the variables into quotation marks to make
> the empty string explicit.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> rules/rootfs.make | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/rules/rootfs.make b/rules/rootfs.make
> index 419ca001e..627d33463 100644
> --- a/rules/rootfs.make
> +++ b/rules/rootfs.make
> @@ -217,11 +217,11 @@ ifdef PTXCONF_ROOTFS_ISSUE
> $(call remove_quotes,$(PTXCONF_ROOTFS_ETC_HOSTNAME)))
> @$(call install_replace_figlet, rootfs, /etc/issue, \
> @FIGLET:VENDOR@, \
> - `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_PROJECT_VENDOR)`, \
> + `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< "$(PTXCONF_PROJECT_VENDOR)"`, \
> etcissue)
> @$(call install_replace_figlet, rootfs, /etc/issue, \
> @FIGLET:HOSTNAME@, \
> - `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< $(PTXCONF_ROOTFS_ETC_HOSTNAME)`, \
> + `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< "$(PTXCONF_ROOTFS_ETC_HOSTNAME)"`, \
> etcissue)
> endif
>
> --
> 2.20.1
>
>
> _______________________________________________
> ptxdist mailing list
> ptxdist@pengutronix.de
> To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ptxdist] [PATCH] rootfs: Fix handling of empty variables
2021-02-03 7:10 ` Michael Olbrich
@ 2021-02-03 7:23 ` Sascha Hauer
2021-02-03 7:28 ` Michael Olbrich
0 siblings, 1 reply; 4+ messages in thread
From: Sascha Hauer @ 2021-02-03 7:23 UTC (permalink / raw)
To: Michael Olbrich; +Cc: ptxdist
On Wed, Feb 03, 2021 at 08:10:59AM +0100, Michael Olbrich wrote:
> On Tue, Feb 02, 2021 at 03:58:36PM +0100, Sascha Hauer wrote:
> > $(PTXCONF_PROJECT_VENDOR) and $(PTXCONF_ROOTFS_ETC_HOSTNAME) can be
> > empty variables in which case bash answers with:
> >
> > /bin/bash: command substitution: line 0: syntax error near unexpected token `newline'
> > /bin/bash: command substitution: line 0: `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< '
>
> This is strange. Why are these variables empty? They are strings in
> kconfig. The resulting make variables should include the quotes, so they
> should never be empty.
To be correct PTXCONF_ROOTFS_ETC_HOSTNAME is not empty, it's just not
defined. That is because ROOTFS_ETC_HOSTNAME depends on ROOTFS_HOSTNAME
which in my case is set to 'n'.
I guess PTXCONF_PROJECT_VENDOR will indeed always have quotes as this
variable doesn't depend on another variable. We could drop this hunk, I
added it for consistency.
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [ptxdist] [PATCH] rootfs: Fix handling of empty variables
2021-02-03 7:23 ` Sascha Hauer
@ 2021-02-03 7:28 ` Michael Olbrich
0 siblings, 0 replies; 4+ messages in thread
From: Michael Olbrich @ 2021-02-03 7:28 UTC (permalink / raw)
To: Sascha Hauer; +Cc: ptxdist
On Wed, Feb 03, 2021 at 08:23:42AM +0100, Sascha Hauer wrote:
> On Wed, Feb 03, 2021 at 08:10:59AM +0100, Michael Olbrich wrote:
> > On Tue, Feb 02, 2021 at 03:58:36PM +0100, Sascha Hauer wrote:
> > > $(PTXCONF_PROJECT_VENDOR) and $(PTXCONF_ROOTFS_ETC_HOSTNAME) can be
> > > empty variables in which case bash answers with:
> > >
> > > /bin/bash: command substitution: line 0: syntax error near unexpected token `newline'
> > > /bin/bash: command substitution: line 0: `sed -r 's/ ?([\.:;,]) ?/ \1 /' <<< '
> >
> > This is strange. Why are these variables empty? They are strings in
> > kconfig. The resulting make variables should include the quotes, so they
> > should never be empty.
>
> To be correct PTXCONF_ROOTFS_ETC_HOSTNAME is not empty, it's just not
> defined. That is because ROOTFS_ETC_HOSTNAME depends on ROOTFS_HOSTNAME
> which in my case is set to 'n'.
>
> I guess PTXCONF_PROJECT_VENDOR will indeed always have quotes as this
> variable doesn't depend on another variable. We could drop this hunk, I
> added it for consistency.
Ah, no I see it. Then it should be:
`... <<< "$(call remove_quotes,$(PTXCONF_ROOTFS_ETC_HOSTNAME))"`
So, remove the quotes if they are there and always add them.
Michael
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to ptxdist-request@pengutronix.de
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-02-03 7:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 14:58 [ptxdist] [PATCH] rootfs: Fix handling of empty variables Sascha Hauer
2021-02-03 7:10 ` Michael Olbrich
2021-02-03 7:23 ` Sascha Hauer
2021-02-03 7:28 ` Michael Olbrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox