Ticket #1360 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

"smoke_languages.pl" doesn't deal with spaces in paths

Reported by: jpaton Owned by: jkeenan
Priority: normal Milestone:
Component: testing Version: 1.8.0
Severity: medium Keywords: space path
Cc: fperrad, jkeenan Language:
Patch status: new Platform: all

Description

Running "smoke_languages.pl" on Windows Vista x64 I get:

C:\Program Files (x86)\Parrot-1.8.0>smoke_languages.pl
1..32
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
not ok 1 - check abc
#   Failed test 'check abc'
#   at C:\Program Files (x86)\Parrot-1.8.0\smoke_languages - Copy.pl line 96.

...

The problem is that "smoke_languages.pl" uses backticks to execute external programs. E.g:

`$command $param`

But when $command contains spaces we have a problem.

Attachments

smoke_languages.pl.path.problem.patch Download (335 bytes) - added by jkeenan 5 years ago.
backslash spaces in paths
smoke_languages.pl.path.problem.2.patch Download (8.1 KB) - added by jpaton 5 years ago.
quotes around command variable in backticks
tt1360.fperrad.patch Download (18.1 KB) - added by jkeenan 5 years ago.
Patch applied in r42947 by François Perrad re wordspaces in paths (Win32-specific)

Change History

in reply to: ↑ description   Changed 5 years ago by jkeenan

  • severity changed from none to medium
  • component changed from none to testing
  • patch set to new
  • priority changed from trivial to minor
  • platform changed from win32 to all
  • keywords space path added

Replying to jpaton:

Running "smoke_languages.pl" on Windows Vista x64 I get: {{{ C:\Program Files (x86)\Parrot-1.8.0>smoke_languages.pl 1..32 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

...

But when $command contains spaces we have a problem.

This is probably not limited to Win32. We've seen this kind of problem before whenever we have spaces in paths.

Would this work for you?

Index: tools/install/smoke_languages.pl
===================================================================
--- tools/install/smoke_languages.pl    (revision 42897)
+++ tools/install/smoke_languages.pl    (working copy)
@@ -61,6 +61,7 @@
 
 chdir($DESTDIR) if ($DESTDIR);
 my $pwd = getcwd();
+$pwd =~ s{ }{\\ }g;
 
 my $filename;
 my $exe;

Changed 5 years ago by jkeenan

backslash spaces in paths

follow-up: ↓ 3   Changed 5 years ago by jpaton

Unfortunately the patch does not fix the problem. Windows now complains thusly:

C:\Program Files (x86)\Parrot-1.8.0>"smoke_languages.pl"
1..32
'C:\Program\' is not recognized as an internal or external command,
operable program or batch file.
ok 1 # skip abc
ok 2 # skip Befunge
ok 3 # skip bf

...

In addition, all 32 of the tests are now skipped which won't be right.

I have written a little test script:

#perl -w

use strict;
use warnings;

my $command = "C:\\Program\ Files\ (x86)\\Parrot-1.8.0\\bin\\parrot";

print "\nNo spaces:\n\n";
print `$command`;

print "\nTrailing spaces:\n\n";
print `$command `;

print "\nWith options:\n\n";
print `$command --version`;

print "\nWith options, with quotes:\n\n";
print `"$command" --version`;

Which gives the following output:


No spaces:

parrot -[acEGhprtvVwy.] [-d [FLAGS]] [-D [FLAGS]][-O [level]]
[-R runcore] [-o FILE] <file>

Trailing spaces:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

With options:

'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

With options, with quotes:

This is Parrot version 1.8.0 built for i386-MSWin32.
Copyright (C) 2001-2009, Parrot Foundation.

This code is distributed under the terms of the Artistic License 2.0.
For more details, see the full text of the license in the LICENSE file
included in the Parrot source tree.


It appears to me that the only solution is to put quotes around the command variable used with backticks.

Changed 5 years ago by jpaton

quotes around command variable in backticks

in reply to: ↑ 2   Changed 5 years ago by jkeenan

  • cc fperrad added

Replying to jpaton:

> Unfortunately the patch does not fix the problem. Windows now complains thusly:
> 
> [snip]
>
> It appears to me that the only solution is to put quotes around the command variable used with backticks.

François, do you think doing something like this throughout the file would be acceptable:

$out = `"$exe" $filename`;

Thank you very much.

kid51

  Changed 5 years ago by jkeenan

  • priority changed from minor to normal
  • cc jkeenan added

François created and applied the attached patch in r42497. However, I suspect we can do even better. This problem will show up a lot on Win32 because the 'Program Files' directory -- and other directories with wordspaces in their names -- is often found there.

But, as I noted above, I think we can and should generalize the solution so that it applies to any operating system which can have wordspaces in path names.

What do people think?

Thank you very much.

kid51

Changed 5 years ago by jkeenan

Patch applied in r42947 by François Perrad re wordspaces in paths (Win32-specific)

  Changed 4 years ago by jkeenan

  • status changed from new to assigned
  • owner set to jkeenan

No comments or complaints in 15 months. I'm closing this ticket. Feel free to open a new one if the problem crops up again.

Thank you very much.

kid51

  Changed 4 years ago by jkeenan

  • status changed from assigned to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.