Hello Gavin,

Answers below...

Le 05/06/2016 à 00:29, Gavin Smith a écrit :
> On 4 June 2016 at 22:40, Vincent Belaïche <[email protected]> wrote:
>> These two things also work:
>>
>> --8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
>>   in_input_funnies=`echo "$in_input" \
>>     | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1\'"
>> "'!g' \
>>     | uniq`
>> --8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----
>>
>> --8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
>>   in_input_funnies=`echo "$in_input" \
>>     | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1\''
>> ''!g' \
>>     | uniq`
>> --8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----
>>
>> but I prefer the one with "$newline" to keep the sed command on the same
>> line.
>
> Nice idea to hide it in a variable.
>

Well, this is not my idea, this is already a tricks that texi2dvi does
with the escape variable.

> I'd come up with
>
> in_input_funnies=`echo "$in_input" \
>     | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1'\\\\'
> ''!g' \
>     | uniq`
>

You don't need the '' at the beginning of 3rd line, the following is OK:

--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
  in_input_funnies=`echo "$in_input" \
    | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1'\\\\'
!g' \
    | uniq`
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

> which is fairly similar to the two examples above you gave, except
> it's less clear. (Four backslashes because backslash escaped once for
> the shell, and once for the ``-expression.)

You can avoid the quadruple backslash by hiding the backslash in $escape
variable, like this:

--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
  in_input_funnies=`echo "$in_input" \
    | $SED -e 's![^}#$%&^_{~]!!g; s!\(.\)!\1'$escape'
!g' \
    | uniq`
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

This would be more consistent with what is done in the rest of the
script --- well there are many places where \\ could be avoided. For
instance in function index_file_p using simple quotes instead of double
quotes would allow to replace all the \\'s by \'s. Similar for the first
\\ in function xref_file_p. Even in the definition of variable escape it
would be simpler to just write:

--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
escape='\'
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

rather than the current:
--8<----8<----8<----8<----8<-- begin -->8---->8---->8---->8---->8----
escape="\\"
--8<----8<----8<----8<----8<--  end  -->8---->8---->8---->8---->8----

Anyway, this is a outside the scope of this discussion.

FYI, I have submitted the following bugs/feature-requests to MikTeX ---
let us not loose from sight that the initial problem raised by Stephen
was spaces in filenames and not supporting any kind of other funny
characters --- even though they are funny.

https://sourceforge.net/p/miktex/bugs/2504/
https://sourceforge.net/p/miktex/feature-requests/336/

VBR,
        Vincent

Reply via email to