2019-06-18 07:21:01

by Michael Forney

[permalink] [raw]
Subject: [PATCH] locking/atomics: Use sed(1) instead of non-standard head(1) option

POSIX says the -n option must be a positive decimal integer. Not all
implementations of head(1) support negative numbers meaning offset from
the end of the file.

Instead, the sed expression '$d' has the same effect of removing the
last line of the file.

Signed-off-by: Michael Forney <[email protected]>
---
scripts/atomic/check-atomics.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/atomic/check-atomics.sh b/scripts/atomic/check-atomics.sh
index cfa0c2f71c84..8378c63a1e09 100755
--- a/scripts/atomic/check-atomics.sh
+++ b/scripts/atomic/check-atomics.sh
@@ -22,7 +22,7 @@ while read header; do
OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})"
OLDSUM="${OLDSUM#// }"

- NEWSUM="$(head -n -1 ${LINUXDIR}/include/${header} | sha1sum)"
+ NEWSUM="$(sed '$d' ${LINUXDIR}/include/${header} | sha1sum)"
NEWSUM="${NEWSUM%% *}"

if [ "${OLDSUM}" != "${NEWSUM}" ]; then
--
2.20.1


2019-06-18 12:18:16

by Will Deacon

[permalink] [raw]
Subject: Re: [PATCH] locking/atomics: Use sed(1) instead of non-standard head(1) option

On Mon, Jun 17, 2019 at 10:33:06PM -0700, Michael Forney wrote:
> POSIX says the -n option must be a positive decimal integer. Not all
> implementations of head(1) support negative numbers meaning offset from
> the end of the file.
>
> Instead, the sed expression '$d' has the same effect of removing the
> last line of the file.
>
> Signed-off-by: Michael Forney <[email protected]>
> ---
> scripts/atomic/check-atomics.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Will Deacon <[email protected]>

Will

2019-06-18 12:54:16

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH] locking/atomics: Use sed(1) instead of non-standard head(1) option

On Tue, Jun 18, 2019 at 01:16:25PM +0100, Will Deacon wrote:
> On Mon, Jun 17, 2019 at 10:33:06PM -0700, Michael Forney wrote:
> > POSIX says the -n option must be a positive decimal integer. Not all
> > implementations of head(1) support negative numbers meaning offset from
> > the end of the file.
> >
> > Instead, the sed expression '$d' has the same effect of removing the
> > last line of the file.
> >
> > Signed-off-by: Michael Forney <[email protected]>
> > ---
> > scripts/atomic/check-atomics.sh | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Acked-by: Will Deacon <[email protected]>

Thanks!

Subject: [tip:locking/core] locking/atomics: Use sed(1) instead of non-standard head(1) option

Commit-ID: ebf8d82bbb32720878a3867b28e655950ccee992
Gitweb: https://git.kernel.org/tip/ebf8d82bbb32720878a3867b28e655950ccee992
Author: Michael Forney <[email protected]>
AuthorDate: Mon, 17 Jun 2019 22:33:06 -0700
Committer: Ingo Molnar <[email protected]>
CommitDate: Tue, 25 Jun 2019 10:17:07 +0200

locking/atomics: Use sed(1) instead of non-standard head(1) option

POSIX says the -n option must be a positive decimal integer. Not all
implementations of head(1) support negative numbers meaning offset from
the end of the file.

Instead, the sed expression '$d' has the same effect of removing the
last line of the file.

Signed-off-by: Michael Forney <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Will Deacon <[email protected]>
Cc: Boqun Feng <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
---
scripts/atomic/check-atomics.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/atomic/check-atomics.sh b/scripts/atomic/check-atomics.sh
index cfa0c2f71c84..8378c63a1e09 100755
--- a/scripts/atomic/check-atomics.sh
+++ b/scripts/atomic/check-atomics.sh
@@ -22,7 +22,7 @@ while read header; do
OLDSUM="$(tail -n 1 ${LINUXDIR}/include/${header})"
OLDSUM="${OLDSUM#// }"

- NEWSUM="$(head -n -1 ${LINUXDIR}/include/${header} | sha1sum)"
+ NEWSUM="$(sed '$d' ${LINUXDIR}/include/${header} | sha1sum)"
NEWSUM="${NEWSUM%% *}"

if [ "${OLDSUM}" != "${NEWSUM}" ]; then