<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>33892</bug_id>
          
          <creation_ts>2017-09-13 21:23:42 +0300</creation_ts>
          <short_desc>--define deletes backslashes from the argument, but this is undocumented and useless</short_desc>
          <delta_ts>2017-11-16 23:06:22 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>rpm</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>enhancement</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ivan Zakharyaschev">imz</reporter>
          <assigned_to name="Gleb F-Malinovskiy">glebfm</assigned_to>
          <cc>arseny</cc>
    
    <cc>glebfm</cc>
    
    <cc>imz</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>165751</commentid>
    <comment_count>0</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-09-13 21:23:42 +0300</bug_when>
    <thetext>rpm --define unexpectedly deletes backslashes from the argument:

$ rpm --define=&quot;foobar &apos;an&apos;&quot; --showrc | fgrep foobar
 -8: foobar	&apos;an&apos;
$ rpm --define=&quot;foobar \&apos;\a\n\&apos;&quot; --showrc | fgrep foobar
 -8: foobar	&apos;an&apos;
$ echo rpm --define=&quot;foobar \&apos;\a\n\&apos;&quot; --showrc
rpm --define=foobar \&apos;\a\n\&apos; --showrc
$ rpm -q rpm
rpm-4.13.0.1-alt1.x86_64
$ 

Is this documented? What&apos;s the use of it?

To be more precise, it deletes a backslash and skips the next character:

$ echo rpm --define=&apos;foobar \\\\\a&apos; --showrc
rpm --define=foobar \\\\\a --showrc
$ rpm --define=&apos;foobar \\\\\a&apos; --showrc | fgrep foobar
 -8: foobar	\\a
$ 

The only use I can think of is escaping a space at the beginning:

$ rpm --define=&apos;foobar \ a&apos; --showrc | fgrep foobar
 -8: foobar	 a
$ rpm --define=&apos;foobar a&apos; --showrc | fgrep foobar
 -8: foobar	a
$</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>167306</commentid>
    <comment_count>1</comment_count>
    <who name="Ivan Zakharyaschev">imz</who>
    <bug_when>2017-11-16 23:06:22 +0300</bug_when>
    <thetext>The use of the backslashes in rpm turns out to be there for multiline values. In spec:

%define foo a\
b

or in command line:

$ rpm --define &apos;foo a\
&gt; b&apos; --eval &apos;%foo&apos;
a
b
$ 

This means we need to escape backslashes and perhaps need a special tool to do this (in scripts). printf %q is an incorrect &quot;overkill&quot; because it does also other kinds of escaping/quoting. Perhaps something like: rpm --define &quot;foo $(sed -e &apos;s:\:\\:g&apos; &lt;&lt;&lt;&quot;$VALUE&quot;)&quot;

$ VALUE=&apos;a\b&apos;
$ echo &quot;$VALUE&quot;
a\b
$ rpm --define &quot;foo $(sed -e &apos;s:\\:\\\\:g&apos; &lt;&lt;&lt;&quot;$VALUE&quot;)&quot; --eval &apos;%foo&apos;
a\b
$</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>