Possible problem in Regexp

Hello, rubyists!

I was attempting to add xscreensavers to my Linux Mint system in

  /usr/share/applications/screensavers

As you can see if you look, if you install all the available
xscreensaver packages there are a LOT of screensaver config files!

8^O

I resolved to offer the community a generalized ruby script to fix
this and many other issues of search and replace.

While doing so, I came across what I believe is a bug in Regexp.

Will people please validate this on various iterations of Ruby, and,
if valid, can somebody pass it to -core?

#!/usr/bin/env ruby

# This file demonstrates what I believe is a a bug
# in Regexp as of 2.2.5r319 (from sources),
# seen on Linux Mint 17.3 MATE
# Usage: .test_regexp 'GNOME' 'GNOME;MATE;'

puts 'String to Regexp source: ' +ARGV[0]
# String to Regexp source: 'GNOME;'

puts 'String to replace source: ' +ARGV[1]
# String to replace source: 'GNOME;MATE;'

r = Regexp.new( ARGV[0])
puts 'Regexp as created: ' + r.to_s
# Regexp as created: (?-mix:'GNOME;')

line = 'OnlyShowIn=GNOME;\n'
puts line
^ OnlyShowIn=GNOME;\n

newlineWRegexp = line.gsub( r, ARGV[1])
newlineRaw = line.gsub( /GNOME;/, ARGV[1])

puts 'Regexp: ' + newlineWRegexp
# Regexp: OnlyShowIn=GNOME;\n

puts 'Raw: ' + newlineRaw
# Raw: OnlyShowIn='GNOME;MATE;'\n

# Process finished with exit code 0

TIA! :smiley:

test_regexp.rb (528 Bytes)

···

--
Don Wilde

# This file demonstrates what I believe is a a bug
# in Regexp as of 2.2.5r319 (from sources),

It would be great if you could write this in something that looks like
colloquial ruby, preferably in the form of a simple test showing both
expected and actual values.

···

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan
Consulting Availability : Silicon Valley or remote

That wasn't simple enough? I thought it was bindingly clear. What I
expected was to have the regexp made from ARGV[0] ('GNOME;') to
perform as well as /GNOME;/

···

--
Don Wilde

That wasn't simple enough? I thought it was bindingly clear. What I
expected was to have the regexp made from ARGV[0] ('GNOME;') to
perform as well as /GNOME;/

The single quotes are part of the pattern in one case but are not in the other. The clue is in the output you shared:

···

On Jun 6, 2016, at 1:28 AM, Don Wilde <dwilde1@gmail.com> wrote:

# Regexp as created: (?-mix:'GNOME;’)

​Not really, I spent a good 10 minutes reading it, then a minute rewriting
the code myself, to understand.

$ cat test_regexp
#!/usr/bin/env ruby

# This file demonstrates what I believe is a a bug
# in Regexp as of 2.2.5r319 (from sources),
# seen on Linux Mint 17.3 MATE
# Usage: ruby test_regexp 'GNOME' 'GNOME;MATE;'

puts "Pattern source: " + ARGV[0].inspect
puts "Replacement: " + ARGV[1].inspect

r = Regexp.new(ARGV[0])
puts "Regexp: " + r.inspect

line = "OnlyShowIn=GNOME;\n"
puts "Original line: " + line.inspect

puts "Substition: " + line.gsub(r, ARGV[1]).inspect
puts "Should be: " + line.gsub(/GNOME;/, ARGV[1]).inspect

$ ruby -v test_regexp 'GNOME;' 'GNOME;MATE;'
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]
Pattern source: "GNOME;"
Replacement: "GNOME;MATE;"
Regexp: /GNOME;/
Original line: "OnlyShowIn=GNOME;\n"
Substition: "OnlyShowIn=GNOME;MATE;\n"
Should be: "OnlyShowIn=GNOME;MATE;\n"
$

Looks alright to me. I changed the 'line' variable to use double-quotes,
since I wasn't sure about that '\n' in there, but it shouldn't make a
difference.

Note that if you invoke it according to your 'usage' comment, you're not
replacing the semicolon, so you end up with two of them in the output:

$ ruby -v test_regexp GNOME 'GNOME;MATE;'
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-linux]
Pattern source: "GNOME"
Replacement: "GNOME;MATE;"
Regexp: /GNOME/
Original line: "OnlyShowIn=GNOME;\n"
Substition: "OnlyShowIn=GNOME;MATE;;\n"
Should be: "OnlyShowIn=GNOME;MATE;\n"
$

But that's not a bug; that's what we call "garbage in, garbage out."

Do you have an example of the wrong output you're seeing?

Cheers

···

On 6 June 2016 at 08:28, Don Wilde <dwilde1@gmail.com> wrote:

That wasn't simple enough? I thought it was bindingly clear. What I
expected was to have the regexp made from ARGV[0] ('GNOME;') to
perform as well as /GNOME;/

--
  Matthew Kerwin
  http://matthew.kerwin.net.au/

Ammar -

But wouldn't that still be a bug? BASH won't accept GNOME; on
thecommand line, would it? I had problems when I tried to include
unquoted /GNOME;/

···

On 6/5/16, Ammar Ali <ammarabuali@gmail.com> wrote:

On Jun 6, 2016, at 1:28 AM, Don Wilde <dwilde1@gmail.com> wrote:

That wasn't simple enough? I thought it was bindingly clear. What I
expected was to have the regexp made from ARGV[0] ('GNOME;') to
perform as well as /GNOME;/

The single quotes are part of the pattern in one case but are not in the
other. The clue is in the output you shared:

# Regexp as created: (?-mix:'GNOME;’)

--
Don Wilde

Ammar -

But wouldn't that still be a bug? BASH won't accept GNOME; on
thecommand line, would it? I had problems when I tried to include
unquoted /GNOME;/

···

On 6/5/16, Ammar Ali <ammarabuali@gmail.com> wrote:

On Jun 6, 2016, at 1:28 AM, Don Wilde <dwilde1@gmail.com> wrote:

That wasn't simple enough? I thought it was bindingly clear. What I
expected was to have the regexp made from ARGV[0] ('GNOME;') to
perform as well as /GNOME;/

The single quotes are part of the pattern in one case but are not in the
other. The clue is in the output you shared:

# Regexp as created: (?-mix:'GNOME;’)

--
Don Wilde

21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ cat arg.rb
#!/usr/bin/env ruby

puts "#{ARGV[0] || 'nah'} #{ARGV[1] || 'nope'}"

21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ ./arg.rb WAT; NOW
WAT nope
bash: NOW: command not found
21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ ./arg.rb WAT\; NOW
WAT; NOW
21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$

HTH,

···

On Sun, Jun 5, 2016 at 8:03 PM, Don Wilde <dwilde1@gmail.com> wrote:

But wouldn't that still be a bug? BASH won't accept GNOME; on
thecommand line, would it? I had problems when I tried to include
unquoted /GNOME;/

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com

twitter: @hassan
Consulting Availability : Silicon Valley or remote

Hassn,

You have completely confused me. I'm honest enough to admit that I do
not know WTF you are talking about. How can this not be as simple as
my example?

···

On 6/5/16, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:

On Sun, Jun 5, 2016 at 8:03 PM, Don Wilde <dwilde1@gmail.com> wrote:

But wouldn't that still be a bug? BASH won't accept GNOME; on
thecommand line, would it? I had problems when I tried to include
unquoted /GNOME;/

21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ cat arg.rb
#!/usr/bin/env ruby

puts "#{ARGV[0] || 'nah'} #{ARGV[1] || 'nope'}"

21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ ./arg.rb WAT;
NOW
WAT nope
bash: NOW: command not found
21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ ./arg.rb WAT\;
NOW
WAT; NOW
21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
Hassan Schroeder | about.me
twitter: @hassan
Consulting Availability : Silicon Valley or remote

--
Don Wilde

Take heart, Don.

In spite of what some say, many here understand your attempt pretty well.

What is not easy to know, is what exactly went wrong for you, since you have not provided exact copy-and-paste of your command line. What transpires from you original post is that at some point you may have managed to have Bash pass the quoting characters as part of the argument. That is, you may have typed something like "'GNOME;'" as the first argument. (Notice how I have used both double quote " and single quote ' characters. In this case, Bash strips the double quote characters and passes the single quotes as part of the argument.

If you look at the response from Ammar Ali, you will see why this transpires from your post. We assume that your comments show output that you have received in earlier runs of the script, and the line that Ammar Ali points out shows the quoting characters included in the value of the regexp.

You ask if this is still a bug. The point is that you use quoting or escaping characters on the command line to tell Bash what you want it to consider as part of the argument. Bash then should remove such quoting characters and pass only the quoted characters. So, how come that the single quotes appeared in the output you rendered in your comments? It is not just in line 16 below, it happens also in lines 9, 12, and 29. If you command line was like your line 6, there should not have been any single quotes in the output!

When I tested it, I was surprised, see below. Perhaps you too have seen something strange.

Testing your script I have been surprised by how Ruby behaves under Cygwin, under Windows. If you are under Linux, this should probably not be of concern to you. This may be related to how the Windows native shell works, or used to work under DOS. The old DOS command.exe did not split the command line into separate words, it just passed the whole command line to the program being run, and left it to that program to do any splitting and quoting. How the modern cmd.exe behaves, I don't know.

I should perhaps note that I am not using a Cygwin port of Ruby, I am running a Windows native Ruby from a Cygwin Bash. Ruby22 and Ruby193.

Anyway, here is my testing:

$ cat -n test.rb
      1 #!/usr/bin/env ruby
      2
      3 # This file demonstrates what I believe is a a bug
      4 # in Regexp as of 2.2.5r319 (from sources),
      5 # seen on Linux Mint 17.3 MATE
      6 # Usage: .test_regexp 'GNOME' 'GNOME;MATE;'
      7
      8 puts 'String to Regexp source: ' +ARGV[0].inspect
      9 # String to Regexp source: 'GNOME;'
     10
     11 puts 'String to replace source: ' +ARGV[1]
     12 # String to replace source: 'GNOME;MATE;'
     13
     14 r = Regexp.new( ARGV[0])
     15 puts 'Regexp as created: ' + r.to_s
     16 # Regexp as created: (?-mix:'GNOME;')
     17
     18 line = 'OnlyShowIn=GNOME;\n'
     19 puts line
     20 # OnlyShowIn=GNOME;\n
     21
     22 newlineWRegexp = line.gsub( r, ARGV[1])
     23 newlineRaw = line.gsub( /GNOME;/, ARGV[1])
     24
     25 puts 'Regexp: ' + newlineWRegexp
     26 # Regexp: OnlyShowIn=GNOME;\n
     27
     28 puts 'Raw: ' + newlineRaw
     29 # Raw: OnlyShowIn='GNOME;MATE;'\n

$ ruby test.rb 'GNOME;' 'GNOME;MATE;'
String to Regexp source: "GNOME;"
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:GNOME;)
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;MATE;\n
Raw: OnlyShowIn=GNOME;MATE;\n

$ ruby test.rb "'GNOME;'" 'GNOME;MATE;'
String to Regexp source: "GNOME;" #<---- What???
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:GNOME;)
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;MATE;\n
Raw: OnlyShowIn=GNOME;MATE;\n

$ ruby test.rb "\'GNOME;\'" 'GNOME;MATE;'
String to Regexp source: "'GNOME;'"
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:'GNOME;')
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;\n
Raw: OnlyShowIn=GNOME;MATE;\n

What surprises me here, is that Ruby seems to do a second parsing of the quoting in the command line arguments!
Surely, Bash works as I expect, passing the single quotes as part of the argument:

$ /bin/echo -n "'GNOME;'" 'GNOME;MATE;' | od -c
0000000 ' G N O M E ; ' G N O M E ; M
0000020 A T E ;
0000024

and for good measure:

$ perl -e 'print "@ARGV"' "'GNOME;'" 'GNOME;MATE;' | od -c
0000000 ' G N O M E ; ' G N O M E ; M
0000020 A T E ;
0000024

(I am piping through "od -c" in order to show all special characters, if there are any.)

Consider what happens when I omit one of the single quotes in the first argument:

ruby test.rb "'GNOME;" 'GNOME;MATE;'
test.rb:11:in `+': can't convert nil into String (TypeError)
         from test.rb:11:in `<main>'
String to Regexp source: "GNOME; GNOME;MATE;"

Line 11 is the one that outputs ARGV[1], the second argument. Apparently the Windows port of ruby interprets quoting characters received from Bash, and when the single quotes are unbalanced, it joined the arguments into one. As a consequence, ARGV[1] was nil.
If instead I use the native Windows command line shell, "cmd.exe", things again work as expected.

···

Den 06.06.2016 07:18, skrev Don Wilde:

Hassn,

You have completely confused me. I'm honest enough to admit that I do
not know WTF you are talking about. How can this not be as simple as
my example?

On 6/5/16, Hassan Schroeder <hassan.schroeder@gmail.com> wrote:

On Sun, Jun 5, 2016 at 8:03 PM, Don Wilde <dwilde1@gmail.com> wrote:

But wouldn't that still be a bug? BASH won't accept GNOME; on
thecommand line, would it? I had problems when I tried to include
unquoted /GNOME;/

21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ cat arg.rb
#!/usr/bin/env ruby

puts "#{ARGV[0] || 'nah'} #{ARGV[1] || 'nope'}"

21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ ./arg.rb WAT;
NOW
WAT nope
bash: NOW: command not found
21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$ ./arg.rb WAT\;
NOW
WAT; NOW
21:14 ~/testcases/standalone(master)[ruby-2.3.1@standalone]$

HTH,
--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
Hassan Schroeder | about.me
twitter: @hassan
Consulting Availability : Silicon Valley or remote

​Hassan was demonstrating how to escape the semicolon character, so bash
wouldn't interpret it as an end-of-command character. It's an alternative
way of passing
'GNOME;'
to ruby as
ARGV[0]

Can I point out that you've said, several times, that your example is very
(patently obviously) simple; yet nobody else here seems to be able to
understand it. This means that either it's not as simple as you think, or
we're all idiots. In either case, the appropriate thing would be for you to
provide more information that might help us understand.

That information could include the following:

* actual correct code (the sample in your original email isn't valid ruby
code, as it has a line that starts with a carat '^')

* a copy-paste (or screenshot, or some other reproduction) of a the exact
command line you entered, and the output it produced

and then, in case it's still not clear:

* exactly which parts of that output do not match your expectations.

Keeping in mind that we are voluntary members of a social group here, and
aren't being paid to provide support, we might be able to give you some
pointers into what's going wrong, how to fix it, and how to avoid similar
issues in future.

But please remember, the burden isn't on us to understand your obvious and
simple problem. If you really do want our help, it would be best to make it
as easy as possible for us to give you that help. Preferably without
insulting us in the process.

Incidentally, did you know that 'sed' is a tool that comes packaged in most
UNIX and Linux distributions, that is useful for performing simple and fast
search-and-replace actions in files?

Cheers

···

On 6 June 2016 at 15:18, Don Wilde <dwilde1@gmail.com> wrote:

Hassn,

You have completely confused me. I'm honest enough to admit that I do
not know WTF you are talking about. How can this not be as simple as
my example?

--
  Matthew Kerwin
  http://matthew.kerwin.net.au/

See also http://sscce.org/

With your original code with a syntax error in line 20 repaired I get this:

$ cat x -n
     1 #!/usr/bin/env ruby
     2
     3 # This file demonstrates what I believe is a a bug
     4 # in Regexp as of 2.2.5r319 (from sources),
     5 # seen on Linux Mint 17.3 MATE
     6 # Usage: .test_regexp 'GNOME' 'GNOME;MATE;'
     7
     8 puts 'String to Regexp source: ' +ARGV[0]
     9 # String to Regexp source: 'GNOME;'
    10
    11 puts 'String to replace source: ' +ARGV[1]
    12 # String to replace source: 'GNOME;MATE;'
    13
    14 r = Regexp.new( ARGV[0])
    15 puts 'Regexp as created: ' + r.to_s
    16 # Regexp as created: (?-mix:'GNOME;')
    17
    18 line = 'OnlyShowIn=GNOME;\n'
    19 puts line
    20 # OnlyShowIn=GNOME;\n
    21
    22 newlineWRegexp = line.gsub( r, ARGV[1])
    23 newlineRaw = line.gsub( /GNOME;/, ARGV[1])
    24
    25 puts 'Regexp: ' + newlineWRegexp
    26 # Regexp: OnlyShowIn=GNOME;\n
    27
    28 puts 'Raw: ' + newlineRaw
    29 # Raw: OnlyShowIn='GNOME;MATE;'\n
    30
    31 # Process finished with exit code 0
$ ruby x 'GNOME;' 'GNOME;MATE;'
String to Regexp source: GNOME;
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:GNOME;)
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;MATE;\n
Raw: OnlyShowIn=GNOME;MATE;\n
$ ruby x GNOME\; GNOME\;MATE\;
String to Regexp source: GNOME;
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:GNOME;)
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;MATE;\n
Raw: OnlyShowIn=GNOME;MATE;\n

Works like a charm.

Kind regards

robert

···

On Mon, Jun 6, 2016 at 8:00 AM, Matthew Kerwin <matthew@kerwin.net.au> wrote:

On 6 June 2016 at 15:18, Don Wilde <dwilde1@gmail.com> wrote:

You have completely confused me. I'm honest enough to admit that I do
not know WTF you are talking about. How can this not be as simple as
my example?

Hassan was demonstrating how to escape the semicolon character, so bash
wouldn't interpret it as an end-of-command character. It's an alternative
way of passing
'GNOME;'
to ruby as
ARGV[0]

Can I point out that you've said, several times, that your example is very
(patently obviously) simple; yet nobody else here seems to be able to
understand it. This means that either it's not as simple as you think, or
we're all idiots. In either case, the appropriate thing would be for you to
provide more information that might help us understand.

That information could include the following:

* actual correct code (the sample in your original email isn't valid ruby
code, as it has a line that starts with a carat '^')

* a copy-paste (or screenshot, or some other reproduction) of a the exact
command line you entered, and the output it produced

and then, in case it's still not clear:

* exactly which parts of that output do not match your expectations.

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

In spite of what some say, many here understand your attempt pretty well.

Please refrain from such statements - unless you can prove you're
psychic and can read minds.

What is not easy to know, is what exactly went wrong for you, since you have
not provided exact copy-and-paste of your command line.

As far as I can see nobody was able to reproduce so far.

What transpires from
you original post is that at some point you may have managed to have Bash
pass the quoting characters as part of the argument. That is, you may have
typed something like "'GNOME;'" as the first argument. (Notice how I have
used both double quote " and single quote ' characters. In this case, Bash
strips the double quote characters and passes the single quotes as part of
the argument.

There is a lot "may" etc. - this is highly speculative. We need hard
facts, the exact way to reproduce the issue.

When I tested it, I was surprised, see below. Perhaps you too have seen
something strange.

Your surprise stems from mixing different architectures and that is
not relevant to the original issue which was reported for Linux Mint.

Testing your script I have been surprised by how Ruby behaves under Cygwin,
under Windows. If you are under Linux, this should probably not be of
concern to you. This may be related to how the Windows native shell works,
or used to work under DOS. The old DOS command.exe did not split the command
line into separate words, it just passed the whole command line to the
program being run, and left it to that program to do any splitting and
quoting. How the modern cmd.exe behaves, I don't know.

Identical.

I should perhaps note that I am not using a Cygwin port of Ruby, I am
running a Windows native Ruby from a Cygwin Bash. Ruby22 and Ruby193.

Anyway, here is my testing:

$ cat -n test.rb

$ ruby test.rb 'GNOME;' 'GNOME;MATE;'
String to Regexp source: "GNOME;"
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:GNOME;)
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;MATE;\n
Raw: OnlyShowIn=GNOME;MATE;\n

$ ruby test.rb "'GNOME;'" 'GNOME;MATE;'
String to Regexp source: "GNOME;" #<---- What???

I cannot reproduce that. With the script from before:

$ ruby x "'GNOME;'" 'GNOME;MATE;'
String to Regexp source: 'GNOME;'
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:'GNOME;')
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;\n
Raw: OnlyShowIn=GNOME;MATE;\n

You can see: only single quotes that would be expected because they
sit inside double quotes.

Note, I am also on Cygwin and using the Cygwin version of Ruby - but I
do not expect any changes vs. Linux.

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-cygwin]

What surprises me here, is that Ruby seems to do a second parsing of the
quoting in the command line arguments!

It does not. At least not for me. All is as expected:

$ bash -c 'echo "$@"' -- 'GNOME;' "'GNOME;'"
GNOME; 'GNOME;'

Consider what happens when I omit one of the single quotes in the first
argument:

ruby test.rb "'GNOME;" 'GNOME;MATE;'
test.rb:11:in `+': can't convert nil into String (TypeError)
        from test.rb:11:in `<main>'
String to Regexp source: "GNOME; GNOME;MATE;"

This seems to be an effect of mixing architectures.

Line 11 is the one that outputs ARGV[1], the second argument. Apparently the
Windows port of ruby interprets quoting characters received from Bash, and
when the single quotes are unbalanced, it joined the arguments into one. As
a consequence, ARGV[1] was nil.

Wait, you use Cygwin and then the Windows version of Ruby? That is
bound to create chaos as on Windows the process is doing the command
line interpretation vs. on Linux (and Cygwin) it is the invoking
shell. You better test this with a Cygwin version of Ruby.

If instead I use the native Windows command line shell, "cmd.exe", things
again work as expected.

Well, see above.

Cheers

robert

···

On Mon, Jun 6, 2016 at 1:56 PM, Enrqiue Perez-Terron <enrique@perezterron.net> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

On Mon, Jun 6, 2016 at 1:56 PM, Enrqiue Perez-Terron

I am sorry, in hindsight my email must read unnecessarily harsh. I
should have taken more time and care in writing. I apologize.

Bottom line is:

I should perhaps note that I am not using a Cygwin port of Ruby, I am
running a Windows native Ruby from a Cygwin Bash. Ruby22 and Ruby193.

Anyway, here is my testing:

$ cat -n test.rb

$ ruby test.rb 'GNOME;' 'GNOME;MATE;'
String to Regexp source: "GNOME;"
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:GNOME;)
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;MATE;\n
Raw: OnlyShowIn=GNOME;MATE;\n

$ ruby test.rb "'GNOME;'" 'GNOME;MATE;'
String to Regexp source: "GNOME;" #<---- What???

I cannot reproduce that. With the script from before:

$ ruby x "'GNOME;'" 'GNOME;MATE;'
String to Regexp source: 'GNOME;'
String to replace source: GNOME;MATE;
Regexp as created: (?-mix:'GNOME;')
OnlyShowIn=GNOME;\n
Regexp: OnlyShowIn=GNOME;\n
Raw: OnlyShowIn=GNOME;MATE;\n

You can see: only single quotes that would be expected because they
sit inside double quotes.

Note, I am also on Cygwin and using the Cygwin version of Ruby - but I
do not expect any changes vs. Linux.

$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-cygwin]

We still need to see the correct script and the command line during
execution from Don...

Kind regards

robert

···

On Mon, Jun 6, 2016 at 5:56 PM, Robert Klemme <shortcutter@googlemail.com> wrote:

--
[guy, jim, charlie].each {|him| remember.him do |as, often| as.you_can
- without end}
http://blog.rubybestpractices.com/

All -

I also must apologize. I don't have time to get back to this this
evening but I couldn't let it stand without making an effort to atone
for my rudeness.

···

--
Don Wilde