Opened 3 years ago

#13308 new bug

Treat leading whitespace in rts flag arguments in a uniform way

Reported by: AndreasK Owned by:
Priority: lowest Milestone:
Component: Runtime System Version: 8.0.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: #4243 Differential Rev(s):
Wiki Page:


When parsing argument flags ghc treats leading whitespace different depending on the flag.

  • ghc +RTS '-N 2' -s -RTS --version

Here '-N 2' is parsed as -N2

  • ghc +RTS '-s file' -RTS --version

Here '-N 2' is parsed as '\ file', a filename starting with a space.

  • ghc +RTS -N 2 -s -RTS --version

Here 2 is a unexpected argument.

The usage info indicates no space is allowed in between flags and arguments making the first point a minor bug.

It's never an issue when executing from a shell since it filters out unquoted spaces, however it can trip someone up when passing arguments explicitly via exec.

If we remove leading spaces for file names however we make it impossible to use filenames starting with whitespace since we cant tell if the space was included by accident or quoted by the shell. But I also have never seen a file starting with whitespace that was created intentionally so maybe that is a worthwhile tradeoff.

If the argument Parser #4243 ever get's rewritten maybe this could be made uniform one way or the other.

Change History (0)

Note: See TracTickets for help on using tickets.