git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] hook: test -a|o is not POSIX

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Jan 9, 2022, 08:14 UTC
Message-ID
<9c7aeb5b-87b2-a51e-c08d-8dfc75ecf588@gmail.com>
In-Reply-To
<pull.1172.git.git.1641528221530.gitgitgadget@gmail.com>
On 07/01/22 11.03, Issam Maghni via GitGitGadget wrote:
Show 57 quoted lines
> From: "Issam E. Maghni" <issam.e.maghni@mailbox.org>
> 
> I faced `test: too many arguments` when building using sbase [1]
> 
> This is due to a non-POSIX syntax `test ... -a ...` and `test … -o …`.
> 
>> The XSI extensions specifying the -a and -o binary primaries and the
>> '(' and ')' operators have been marked obsolescent.
> [2]
> 
> [1] https://core.suckless.org/sbase/
> [2] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> 
> Signed-off-by: Issam E. Maghni <issam.e.maghni@mailbox.org>
> ---
>      shell: test -a|o is not POSIX
>      
>      I faced test: too many arguments when building using sbase
>      [https://core.suckless.org/sbase/]. This is due to a non-POSIX syntax
>      test ... -a ... and test … -o ….
>      
>      > The XSI extensions specifying the -a and -o binary primaries and the
>      > '(' and ')' operators have been marked obsolescent.
>      
>      https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1172%2Fconcatime%2Fpatch-1-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1172/concatime/patch-1-v1
> Pull-Request: https://github.com/git/git/pull/1172
> 
>   templates/hooks--update.sample | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
> index c4d426bc6ee..6cc46ebcf3a 100755
> --- a/templates/hooks--update.sample
> +++ b/templates/hooks--update.sample
> @@ -37,7 +37,7 @@ if [ -z "$GIT_DIR" ]; then
>   	exit 1
>   fi
>   
> -if [ -z "$refname" -o -z "$oldrev" -o -z "$newrev" ]; then
> +if [ -z "$refname" ] || [ -z "$oldrev" ] || [ -z "$newrev" ]; then
>   	echo "usage: $0 <ref> <oldrev> <newrev>" >&2
>   	exit 1
>   fi
> @@ -95,7 +95,7 @@ case "$refname","$newrev_type" in
>   		;;
>   	refs/heads/*,commit)
>   		# branch
> -		if [ "$oldrev" = "$zero" -a "$denycreatebranch" = "true" ]; then
> +		if [ "$oldrev" = "$zero" ] && [ "$denycreatebranch" = "true" ]; then
>   			echo "*** Creating a branch is not allowed in this repository" >&2
>   			exit 1
>   		fi
> 
> base-commit: 2ae0a9cb8298185a94e5998086f380a355dd8907
 From the patch above, the title should be "replace non-POSIX test -a & test -o with logical operator".
-- 
An old man doll... just what I always wanted! - Clara
Previous: Issam E. MaghniNext: Junio C Hamano
Message 4 of 5 in “hook: test -a|o is not POSIX”
  1. hook: test -a|o is not POSIXIssam Maghni via GitGitGadget, Jan 7, 2022
  2. Junio C HamanoJan 7, 2022
  3. Issam E. MaghniJan 7, 2022
  4. Bagas SanjayaJan 9, 2022
  5. Junio C HamanoJan 9, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.