All of lore.kernel.org
 help / color / mirror / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Felipe Contreras" <felipe.contreras@gmail.com>
Subject: [PATCH 1/2] test: fix build for zsh
Date: Fri, 31 Mar 2023 19:56:31 -0600	[thread overview]
Message-ID: <20230401015632.103581-2-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20230401015632.103581-1-felipe.contreras@gmail.com>

zsh has the ability to emulate Bourne shell, which is closer to what our
testing suite expect.

Using the POSIX_ARGZERO option makes $0 behave as POSIX seems to define:
show the name of the command launched, as opposed to the zsh default:
the path of the script.

This enables many tests, but not all.

We can run the tests with `zsh --emulate sh` which has more more
compatibility, but doing `emulate sh` inside the script allows us to
just use `zsh`, although it's not as compatible.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/test-lib.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 62136caee5..d5a9168484 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -15,6 +15,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see http://www.gnu.org/licenses/ .
 
+if test -n "${ZSH_VERSION-}"
+then
+	emulate sh -o POSIX_ARGZERO
+fi
+
 # Test the binaries we have just built.  The tests are kept in
 # t/ subdirectory and are run in 'trash directory' subdirectory.
 if test -z "$TEST_DIRECTORY"
-- 
2.40.0


  reply	other threads:[~2023-04-01  1:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-01  1:56 [PATCH 0/2] test: add support for zsh and zsh completion Felipe Contreras
2023-04-01  1:56 ` Felipe Contreras [this message]
2023-04-01  5:33   ` [PATCH 1/2] test: fix build for zsh Eric Sunshine
2023-04-01  1:56 ` [PATCH 2/2] test: completion: add zsh tests Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230401015632.103581-2-felipe.contreras@gmail.com \
    --to=felipe.contreras@gmail.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.