On 2021/03/02 0:41, Daniel Shahaf wrote:
> Yasuhito FUTATSUKI wrote on Mon, Mar 01, 2021 at 10:55:51 +0900:
>> On 2021/02/26 22:52, Daniel Shahaf wrote:
>>> Yasuhito FUTATSUKI wrote on Thu, Feb 25, 2021 at 21:43:15 +0900:
>>>> On 2021/02/22 13:39, Karl Fogel wrote:

>>>> (A) Replace the shebang line of svneditor.py from svneditor.py
>>>>   at running the configure script. (fix-svneditor-in-test-patch-a.txt)
>>>>   As @PYTHON@ can be basename only, relative path, or absolute path,
>>>>   "/usr/bin/env" is still needed.
>>>>
>>>> (B) Make a script to launch svneditor.py using @PYTHON@, svneditor.sh
>>>>   at running the configure scriptt. (fix-svneditor-in-test-patch-b.txt)
>>>>
>>>> If @PYTHON@ is always absolute path, we can use shebang line without
>>>> '/usr/bin/env' in patch (A).
>>>>
>>>> Cheers,
>>>
>>> I take it the two patches are alternatives?  If so, I prefer (B), because:
>>>
>>> - .in files get in the way of the edit-compile-fix cycle, and the file
>>>   that (B) makes .in is less likely to need to be edited.
>>>
>>> - Using @PYTHON@ in a #!/bin/sh script is closer to its existing uses
>>>   (in Makefile.in, for example) than using it on the #! line.
>>  
>> Thank you for the comment. It is reasonable. 
>>
>> So I looked at patch (B) more closely and updated, so that the substituted
>> string is not interpreted specially by the shell. As this uses function,
>> it does not work with v7 sh but POSIX shells allows to use it.
> 
> Thanks for the revision.  I'm happy to leave it to you to choose between
> the two versions of (B).  I'll just share two (more) observations:

Thank you.

>> +++ subversion/tests/cmdline/svneditor.sh.in (working copy)
>> @@ -0,0 +1,40 @@
>> +print_python_path()
>> +{
>> +cat <<"_SVN_EOF"
>> +@PYTHON@x
>> +_SVN_EOF
>> +}
> 
> I don't see any value of @PYTHON@ that would benefit from being
> carefully unescaped like this, since Makefile.in already assumes that
> @PYTHON@ can be used either bare or in double quotes:

Then, it is just same for expansion of @abs_srcdir@. As the use of
abs_srcdir in Makefile is not quoted, expansion of @abs_srcdir@ in
svneditor.sh can be used without quotes, putting aside which is
good embedding path statically or setting it at run time.

>> +python="$(print_python_path)"
>> +python="${python%x}"
>> +
>> +script_dir="`cd $(dirname "$0"); pwd`"
>> +
> 
> If «$0» needs quoting, then quotes are needed around the «$(…)»
> construct as well.

Sure. And the result of the observation above, bare $0 can be used here,
unless the scripts are moved or copied to another place. To launch
svneditor.py script $script_dir can be relative path, this can be simply,

    script_dir=`dirname "$0"`

Thus, a launcher script (without file header) can be

[[[
script_dir=`dirname "$0"`
exec @PYTHON@ "$script_dir"/svneditor.py "$@"
]]]

or one in previous revision of patch (B).

Cheers,
-- 
Yasuhito FUTATSUKI <futat...@yf.bsclub.org>

Reply via email to