* [PATCH] config: simplify profile.*sh.in @ 2022-01-17 16:22 наб 2022-01-18 16:13 ` Frank Ch. Eigler 0 siblings, 1 reply; 6+ messages in thread From: наб @ 2022-01-17 16:22 UTC (permalink / raw) To: elfutils-devel [-- Attachment #1: Type: text/plain, Size: 2491 bytes --] 1. Remove needless profile=@profile@ 2. Simplify needless sh -c "cat glob 2>/dev/null" into cat glob 2>/dev/null 3. Use $( instead of ` under sh 4. Assign to D_U directly and either export it or unset it Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> --- Please keep me in CC, as I'm not subscribed config/profile.csh.in | 12 +++++------- config/profile.sh.in | 11 ++--------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/config/profile.csh.in b/config/profile.csh.in index 01f7c2f2..2495aaa0 100644 --- a/config/profile.csh.in +++ b/config/profile.csh.in @@ -1,4 +1,3 @@ - # $HOME/.login* or similar files may first set $DEBUGINFOD_URLS. # If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. # $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. @@ -6,11 +5,10 @@ # such as $DEBUGINFOD_MAXSIZE, $DEBUGINFOD_MAXTIME, $DEBUGINFOD_PROGRESS. if (! $?DEBUGINFOD_URLS) then - set prefix="@prefix@" - set debuginfod_urls=`sh -c "cat @sysconfdir@/debuginfod/*.urls 2>/dev/null" | tr '\n' ' '` - if ( "$debuginfod_urls" != "" ) then - setenv DEBUGINFOD_URLS "$debuginfod_urls" + set DEBUGINFOD_URLS=`cat @sysconfdir@/debuginfod/*.urls 2>/dev/null | tr '\n' ' '` + if ( "$DEBUGINFOD_URLS" != "" ) then + setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS" + else + unset DEBUGINFOD_URLS endif - unset debuginfod_urls - unset prefix endif diff --git a/config/profile.sh.in b/config/profile.sh.in index afce3963..1fc6d6ed 100644 --- a/config/profile.sh.in +++ b/config/profile.sh.in @@ -1,4 +1,3 @@ - # $HOME/.profile* or similar files may first set $DEBUGINFOD_URLS. # If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. # $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. @@ -6,12 +5,6 @@ # such as $DEBUGINFOD_MAXSIZE, $DEBUGINFOD_MAXTIME, $DEBUGINFOD_PROGRESS. if [ -z "$DEBUGINFOD_URLS" ]; then - prefix="@prefix@" - debuginfod_urls=`sh -c "cat @sysconfdir@/debuginfod/*.urls 2>/dev/null" | tr '\n' ' '` - if [ -n "$debuginfod_urls" ]; then - DEBUGINFOD_URLS="$debuginfod_urls" - export DEBUGINFOD_URLS - fi - unset debuginfod_urls - unset prefix + DEBUGINFOD_URLS=$(cat @sysconfdir@/debuginfod/*.urls 2>/dev/null | tr '\n' ' ') + [ -n "$DEBUGINFOD_URLS" ] && export DEBUGINFOD_URLS || unset DEBUGINFOD_URLS fi -- 2.34.1 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] config: simplify profile.*sh.in 2022-01-17 16:22 [PATCH] config: simplify profile.*sh.in наб @ 2022-01-18 16:13 ` Frank Ch. Eigler 2022-01-19 12:31 ` [PATCH v2] " наб 0 siblings, 1 reply; 6+ messages in thread From: Frank Ch. Eigler @ 2022-01-18 16:13 UTC (permalink / raw) To: наб; +Cc: elfutils-devel Hi - > 1. Remove needless profile=@profile@ You mean "prefix=@prefix@". And it's not needless, because @sysconfdir@ often expands to "$prefix/something", which requires a prefix var to be set for evaluation. > 2. Simplify needless sh -c "cat glob 2>/dev/null" > into cat glob 2>/dev/null This is not needless, but I forget the exact details. It probably has to do with the $prefix expansion just above, or perhaps glob non-matching error handling. > 3. Use $( instead of ` under sh I'm neutral on this, assuming it's not a bashism. > 4. Assign to D_U directly and either export it or unset it I'm neutral on this. - FChE ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2] config: simplify profile.*sh.in 2022-01-18 16:13 ` Frank Ch. Eigler @ 2022-01-19 12:31 ` наб 2022-04-15 11:48 ` Mark Wielaard 0 siblings, 1 reply; 6+ messages in thread From: наб @ 2022-01-19 12:31 UTC (permalink / raw) To: Frank Ch. Eigler; +Cc: elfutils-devel [-- Attachment #1: Type: text/plain, Size: 3559 bytes --] Hi! On Tue, Jan 18, 2022 at 11:13:28AM -0500, Frank Ch. Eigler wrote: > You mean "prefix=@prefix@". And it's not needless, > because @sysconfdir@ often expands to "$prefix/something", > which requires a prefix var to be set for evaluation. I did, and yeah, that's right. Guess it was so outlandish that I completely missed it. Dropped. > > 2. Simplify needless sh -c "cat glob 2>/dev/null" > > into cat glob 2>/dev/null > This is not needless, but I forget the exact details. It probably has > to do with the $prefix expansion just above, or perhaps glob > non-matching error handling. Well, no, as-written, it is needless. It's also incorrect, since it's subject to word-splitting (=> a broken glob) again. But, yeah, turns out csh does have "glob non-matching error handing", which is both news to me and a blast from a V3-era past. That being said, it was also broken, because under csh false | cat fails, for some inexplicable reason, and if the glob "fails", so does cat, so so does sh. I've restored it, in a fashion that isn't subject to re-splitting, and actually protects -e mode, for csh. v2 scissor-patch below. Please keep me in CC, as I'm not subscribed, наб -- >8 -- 1. Simplify needless sh -c "cat glob 2>/dev/null" into cat glob 2>/dev/null under sh and fix re-expansion/-e protection under csh 2. Use $( instead of ` under sh 3. Assign to D_U directly and either export it or unset it Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> --- config/profile.csh.in | 10 +++++----- config/profile.sh.in | 9 ++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/config/profile.csh.in b/config/profile.csh.in index 01f7c2f2..012e243a 100644 --- a/config/profile.csh.in +++ b/config/profile.csh.in @@ -1,4 +1,3 @@ - # $HOME/.login* or similar files may first set $DEBUGINFOD_URLS. # If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. # $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. @@ -7,10 +6,11 @@ if (! $?DEBUGINFOD_URLS) then set prefix="@prefix@" - set debuginfod_urls=`sh -c "cat @sysconfdir@/debuginfod/*.urls 2>/dev/null" | tr '\n' ' '` - if ( "$debuginfod_urls" != "" ) then - setenv DEBUGINFOD_URLS "$debuginfod_urls" + set DEBUGINFOD_URLS=`sh -c 'cat "$0"/*.urls; :' "@sysconfdir@/debuginfod" 2>/dev/null | tr '\n' ' '` + if ( "$DEBUGINFOD_URLS" != "" ) then + setenv DEBUGINFOD_URLS "$DEBUGINFOD_URLS" + else + unset DEBUGINFOD_URLS endif - unset debuginfod_urls unset prefix endif diff --git a/config/profile.sh.in b/config/profile.sh.in index afce3963..bad20b1e 100644 --- a/config/profile.sh.in +++ b/config/profile.sh.in @@ -1,4 +1,3 @@ - # $HOME/.profile* or similar files may first set $DEBUGINFOD_URLS. # If $DEBUGINFOD_URLS is not set there, we set it from system *.url files. # $HOME/.*rc or similar files may then amend $DEBUGINFOD_URLS. @@ -7,11 +6,7 @@ if [ -z "$DEBUGINFOD_URLS" ]; then prefix="@prefix@" - debuginfod_urls=`sh -c "cat @sysconfdir@/debuginfod/*.urls 2>/dev/null" | tr '\n' ' '` - if [ -n "$debuginfod_urls" ]; then - DEBUGINFOD_URLS="$debuginfod_urls" - export DEBUGINFOD_URLS - fi - unset debuginfod_urls + DEBUGINFOD_URLS=$(cat "@sysconfdir@/debuginfod"/*.urls 2>/dev/null | tr '\n' ' ') + [ -n "$DEBUGINFOD_URLS" ] && export DEBUGINFOD_URLS || unset DEBUGINFOD_URLS unset prefix fi -- 2.34.1 [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] config: simplify profile.*sh.in 2022-01-19 12:31 ` [PATCH v2] " наб @ 2022-04-15 11:48 ` Mark Wielaard 2022-04-15 12:12 ` наб 0 siblings, 1 reply; 6+ messages in thread From: Mark Wielaard @ 2022-04-15 11:48 UTC (permalink / raw) To: наб, Frank Ch. Eigler; +Cc: elfutils-devel Hi, On Wed, 2022-01-19 at 13:31 +0100, наб via Elfutils-devel wrote: > On Tue, Jan 18, 2022 at 11:13:28AM -0500, Frank Ch. Eigler wrote: > > You mean "prefix=@prefix@". And it's not needless, > > because @sysconfdir@ often expands to "$prefix/something", > > which requires a prefix var to be set for evaluation. > > I did, and yeah, that's right. Guess it was so outlandish that I > completely missed it. Dropped. > > > > 2. Simplify needless sh -c "cat glob 2>/dev/null" > > > into cat glob 2>/dev/null > > > > This is not needless, but I forget the exact details. It probably > > has > > to do with the $prefix expansion just above, or perhaps glob > > non-matching error handling. > > Well, no, as-written, it is needless. It's also incorrect, > since it's subject to word-splitting (=> a broken glob) again. > > But, yeah, turns out csh does have "glob non-matching error handing", > which is both news to me and a blast from a V3-era past. > That being said, it was also broken, because under csh > false | cat > fails, for some inexplicable reason, and if the glob "fails", > so does cat, so so does sh. > > I've restored it, in a fashion that isn't subject to re-splitting, > and actually protects -e mode, for csh. > > v2 scissor-patch below. > > Please keep me in CC, as I'm not subscribed, > наб > > -- >8 -- > 1. Simplify needless sh -c "cat glob 2>/dev/null" > into cat glob 2>/dev/null under sh > and fix re-expansion/-e protection under csh > 2. Use $( instead of ` under sh > 3. Assign to D_U directly and either export it or unset it This seems reasonable to me, but I did have to lookup the exact workings of sh -c to make sense of it. -c string If the -c option is present, then commands are read from string. If there are arguments after the string, they are assigned to the positional parameters, starting with $0. I have added a ChangeLog entry: 2022-01-19 Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> * profile.csh.in: Set DEBUGINFOD_URLS directly. Use "$0" and : in sh -c. * profile.sh.in: Set DEBUGINFOD_URLS directly. Don't use sh -c. Use $() instead of ``. Full commit at: https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=simplify-profile Frank, do you have any more concerns with this patch? Ahelenia, under which shells have you tested this? Thanks, Mark ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] config: simplify profile.*sh.in 2022-04-15 11:48 ` Mark Wielaard @ 2022-04-15 12:12 ` наб 2022-04-23 0:32 ` Mark Wielaard 0 siblings, 1 reply; 6+ messages in thread From: наб @ 2022-04-15 12:12 UTC (permalink / raw) To: Mark Wielaard; +Cc: Frank Ch. Eigler, elfutils-devel [-- Attachment #1: Type: text/plain, Size: 780 bytes --] Hi! On Fri, Apr 15, 2022 at 01:48:23PM +0200, Mark Wielaard wrote: > I have added a ChangeLog entry: > > 2022-01-19 Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> > > * profile.csh.in: Set DEBUGINFOD_URLS directly. Use "$0" and : > in sh -c. > * profile.sh.in: Set DEBUGINFOD_URLS directly. Don't use sh -c. > Use $() instead of ``. > > Full commit at: > https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=simplify-profile Yeah, that looks about right. > Ahelenia, under which shells have you tested this? csh, dash, and bash, whichever versions were current in sid x32 when I posted this (not that it matters much, I think, the sh version is specified by POSIX, and csh is unchanging). Best, наб [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] config: simplify profile.*sh.in 2022-04-15 12:12 ` наб @ 2022-04-23 0:32 ` Mark Wielaard 0 siblings, 0 replies; 6+ messages in thread From: Mark Wielaard @ 2022-04-23 0:32 UTC (permalink / raw) To: наб; +Cc: elfutils-devel Hi наб, On Fri, Apr 15, 2022 at 02:12:31PM +0200, наб via Elfutils-devel wrote: > On Fri, Apr 15, 2022 at 01:48:23PM +0200, Mark Wielaard wrote: > > I have added a ChangeLog entry: > > > > 2022-01-19 Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> > > > > * profile.csh.in: Set DEBUGINFOD_URLS directly. Use "$0" and : > > in sh -c. > > * profile.sh.in: Set DEBUGINFOD_URLS directly. Don't use sh -c. > > Use $() instead of ``. > > > > Full commit at: > > https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=simplify-profile > > Yeah, that looks about right. > > > Ahelenia, under which shells have you tested this? > csh, dash, and bash, whichever versions were current in sid x32 > when I posted this (not that it matters much, I think, > the sh version is specified by POSIX, and csh is unchanging). Thanks, pushed now, Mark ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-04-23 0:32 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-17 16:22 [PATCH] config: simplify profile.*sh.in наб 2022-01-18 16:13 ` Frank Ch. Eigler 2022-01-19 12:31 ` [PATCH v2] " наб 2022-04-15 11:48 ` Mark Wielaard 2022-04-15 12:12 ` наб 2022-04-23 0:32 ` Mark Wielaard
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).