Re: test_pause giving '__git_ps1: not found' warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jan 14, 2023 at 05:49:15PM +0000, Philip Oakley wrote:

> On 14/01/2023 14:54, Philip Oakley wrote:
> > I was trying to refine a test_expect_failure test [1] and tried
> > inserting a `test_pause &&` test line [2].
> > 
> > I then found, when it paused, I was repeatedly given the warning line
> >     /bin/sh: 1: __git_ps1: not found
> > in the terminal until I expected the test shell.
> > 
> > my PS1 is working normally in the terminal, but not here.  Is this
> > expected, or do I need to set up anything else?
> > 
> > Normally I'm on Git for Windows, but this was on my old laptop (Acer
> > 7741 i5 4GB ram..) converted to Ubuntu 20.04, which I use when away.

On Ubuntu, your /bin/sh is likely to be dash. And unless you've set
TEST_SHELL_PATH, that's what test_pause will use.

> My local .bashrc has
> 
>     . /home/philip/git-completion.bash
>     . ~/git-prompt.sh
>     export GIT_PS1_SHOWDIRTYSTATE=1
>     export PS1='\w$(__git_ps1 " (%s)")\$ '

It's unusual to export PS1. Only the shell needs it. But by exporting
it, the child "dash" will see it, but of course doesn't have the
__git_ps1() function defined. And thus the complaint.

If you stop exporting it, then you'd see dash's regular prompt. Which
fixes the "whoops, __git_ps1() is not defined" problem, but probably is
not quite what you want, if you really wanted a nice prompt.

> Not sure why I have a relative and an absolute path but... ,  so I'll try
> updating the git-prompt.sh to an absolute path, and if that works, maybe
> think about adding an extra comment to the `test-lib-functions.sh` to note
> the change of HOME and potential '__git_ps1' problem

It looks like test_pause() has various options for retaining shell,
term, home, etc, and includes documentation. I haven't played with them
myself, though. Usually I just use "-i" to stop the test, and then
investigate the result in one of my regular shells (and in the rare case
of "oops, it succeeds when I expect it to fail, I insert "false &&" as
appropriate).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux