threads / patch / 10319

patchgit-commit.sh: Remove option -n from tail

Subject: [PATCH] git-commit.sh: Remove option -n from tail

## tl;dr

10 messages between Oct 16, 2007 and Oct 16, 2007. Diffs are folded; open one to read it.

replies: 9people: 6as markdown or json

Jari Aalto· Oct 16, 2007, 16:57 UTC · lore

[PATCH] tail -n not supported in all OSs

SunOS/Solaris tail(1) does not support option '-n'. The following patches change occurrances of:

   tail -n <N>
to
   tail <N>

--------------------------------------------------------------------- REFERENCES:

User Commands                                             TAIL(1)
                        
NAME
     tail - output the last part of files
SYNOPSIS
     tail [OPTION]... [FILE]...
- - -

$ uname -a SunOS host 5.9 Generic_118558-35 sun4u sparc SUNW,Serverblade1

$ echo | tail -n 1
usage: tail [+/-[n][lbc][f]] [file]
       tail [+/-[n][l][r|f]] [file]                     
Jari Aalto· Oct 16, 2007, 16:57 UTC · re: Jari Aalto · lore

[PATCH] git-am.sh: Remove option -n from tail

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 git-am.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Show changes to git-am.sh +3 −1
diff --git a/git-am.sh b/git-am.sh
index b02ae6a..09a991c 100755
--- a/git-am.sh
+++ b/git-am.sh
@@ -2,6 +2,8 @@
 #
 # Copyright (c) 2005, 2006 Junio C Hamano
 
+TAIL="tail"
+
 USAGE='[--signoff] [--dotest=<dir>] [--keep] [--utf8 | --no-utf8]
   [--3way] [--interactive] [--binary]
   [--whitespace=<option>] [-C<n>] [-p<n>]
@@ -321,7 +323,7 @@ do
 		LAST_SIGNED_OFF_BY=`
 		    sed -ne '/^Signed-off-by: /p' \
 		    "$dotest/msg-clean" |
-		    tail -n 1
+		    $TAIL 1
 		`
 		ADD_SIGNOFF=`
 		    test "$LAST_SIGNED_OFF_BY" = "$SIGNOFF" || {
-- 
1.5.3.2.81.g17ed
Jari Aalto· Oct 16, 2007, 16:57 UTC · re: Jari Aalto · lore
Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 git-commit.sh |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
Show changes to git-commit.sh +4 −2
diff --git a/git-commit.sh b/git-commit.sh
index fcb8443..637cf48 100755
--- a/git-commit.sh
+++ b/git-commit.sh
@@ -3,6 +3,8 @@
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2006 Junio C Hamano
 
+TAIL="tail"
+
 USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [--template <file>] [[-i | -o] <path>...]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
@@ -442,10 +444,10 @@ t)
 		s/^/Signed-off-by: /
 		')
 	blank_before_signoff=
-	tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
+	$TAIL 1 "$GIT_DIR"/COMMIT_EDITMSG |
 	grep 'Signed-off-by:' >/dev/null || blank_before_signoff='
 '
-	tail -n 1 "$GIT_DIR"/COMMIT_EDITMSG |
+	$TAIL 1 "$GIT_DIR"/COMMIT_EDITMSG |
 	grep "$sign"$ >/dev/null ||
 	printf '%s%s\n' "$blank_before_signoff" "$sign" \
 		>>"$GIT_DIR"/COMMIT_EDITMSG
-- 
1.5.3.2.81.g17ed
Jari Aalto· Oct 16, 2007, 16:57 UTC · re: Jari Aalto · lore

[PATCH] git-rebase--interactive.sh: Remove option -n from tail

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
---
 git-rebase--interactive.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Show changes to git-rebase--interactive.sh +3 −1
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 050140d..58e164c 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -10,6 +10,8 @@
 # The original idea comes from Eric W. Biederman, in
 # http://article.gmane.org/gmane.comp.version-control.git/22407
 
+TAIL="tail"
+
 USAGE='(--continue | --abort | --skip | [--preserve-merges] [--verbose]
 	[--onto <branch>] <upstream> [<branch>])'
 
@@ -204,7 +206,7 @@ nth_string () {
 make_squash_message () {
 	if test -f "$SQUASH_MSG"; then
 		COUNT=$(($(sed -n "s/^# This is [^0-9]*\([1-9][0-9]*\).*/\1/p" \
-			< "$SQUASH_MSG" | tail -n 1)+1))
+			< "$SQUASH_MSG" | $TAIL 1)+1))
 		echo "# This is a combination of $COUNT commits."
 		sed -n "2,\$p" < "$SQUASH_MSG"
 	else
-- 
1.5.3.2.81.g17ed
Johannes Schindelin· Oct 16, 2007, 17:18 UTC · re: Jari Aalto · lore

Re: [PATCH] git-commit.sh: Remove option -n from tail

Hi,
On Tue, 16 Oct 2007, Jari Aalto wrote:
> Signed-off-by: Jari Aalto <jari.aalto@cante.net>
Rationale?

And also, can't this wait for the builtin-commit, which will solve this problem?

Ciao, Dscho

David Brown· Oct 16, 2007, 17:12 UTC · re: Jari Aalto · lore

Re: [PATCH] tail -n not supported in all OSs

On Tue, Oct 16, 2007 at 07:57:14PM +0300, Jari Aalto wrote:
Show 9 quoted lines
>
>SunOS/Solaris tail(1) does not support option '-n'. The
>following patches change occurrances of:
>
>   tail -n <N>
>
>to
>
>   tail <N>
On Linux, I get
   tail: cannot open `1' for reading: No such file or directory
Did you want
   tail -<N>
David
YOSHIFUJI Hideaki / 吉藤英明· Oct 16, 2007, 17:16 UTC · re: Jari Aalto · lore

Re: [PATCH] tail -n not supported in all OSs

In article <1192553837-18302-1-git-send-email-jari.aalto@cante.net> (at Tue, 16 Oct 2007 19:57:14 +0300), Jari Aalto <jari.aalto@cante.net> says:
Show 9 quoted lines
> 
> SunOS/Solaris tail(1) does not support option '-n'. The
> following patches change occurrances of:
> 
>    tail -n <N>
> 
> to
> 
>    tail <N>
You should say "tail -<N>".
--yoshfuji
Florian Weimer· Oct 16, 2007, 20:37 UTC · re: Jari Aalto · lore

Re: [PATCH] tail -n not supported in all OSs

* Jari Aalto:
Show 7 quoted lines
> $ uname -a
> SunOS host 5.9 Generic_118558-35 sun4u sparc SUNW,Serverblade1
>
> $ echo | tail -n 1
>
> usage: tail [+/-[n][lbc][f]] [file]
>        tail [+/-[n][l][r|f]] [file]                     
What about /usr/xpg4/bin/tail?  Why aren't you using that?
Theodore Tso· Oct 16, 2007, 22:06 UTC · re: Jari Aalto · lore

Re: [PATCH] tail -n not supported in all OSs

On Tue, Oct 16, 2007 at 07:57:14PM +0300, Jari Aalto wrote:
Show 9 quoted lines
> 
> SunOS/Solaris tail(1) does not support option '-n'. The
> following patches change occurrances of:
> 
>    tail -n <N>
> 
> to
> 
>    tail <N>

POSIX.2 guarantees that "tail -n 2" works. "Tail -<N>" is considered obsolete. Unfortunately Solaris requires you to use /usr/xpg4/bin/tail if you want a POSIX.2 compliant header file. The /usr/bin/tail is designed for System V R3 compliance (i.e., from a full two decades ago; SVR3 was released in 1987), and is due to Sun's vow to Backwards Compatible Forever.

See "man 5 standards" on a Solaris box to see how your PATH variable has to be set if you want something which is compatible with modern Unix/Linux common usage.

					- Ted

← back to recent threads