Bug 1248418 - "scl enable" strips double quotes in command arguments [NEEDINFO]
Summary: "scl enable" strips double quotes in command arguments
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: scl-utils
Version: 8.1
Hardware: Unspecified
OS: Unspecified
medium
unspecified
Target Milestone: rc
: 8.1
Assignee: Packaging Maintenance Team
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On: 1681083
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-07-30 09:06 UTC by Dominic Cleal
Modified: 2019-12-11 15:52 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-12-11 15:52:02 UTC
Type: Bug
Target Upstream Version:
dmach: needinfo? (lzachar)


Attachments (Terms of Use)

Description Dominic Cleal 2015-07-30 09:06:04 UTC
Description of problem:
Commands with arguments containing double quotes run through "scl enable" have the quotes stripped out.  This seems to happen during creation of the bash script internally.

This is problematic when passing JSON through as an argument to a command.

Version-Release number of selected component (if applicable):
scl-utils-20130529-17.el7

How reproducible:
Always

Steps to Reproduce:
1. Create /usr/bin/argprint with the following contents:

#!/bin/bash
for a in "$@"; do echo $a; done

2. scl enable ruby193 -- argprint a '["b"]'

Actual results:
a
[b]

Expected results:
a
["b"]

Additional info:

Comment 7 Michal Domonkos 2019-12-11 15:52:02 UTC
While this is a valid issue and we should indeed wrap the arguments in single quotes instead of double quotes (and escape any inner single quotes), changing the code at this point could break existing scripts that rely on the current behavior for one reason or another.  As an example, consider the following command:

  # scl enable <collection> -- echo '$PATH'

Currently, this would internally translate into calling
  echo "$PATH"
and thus printing the $PATH value as configured within the collection environment.

If we changed the code so that single quotes were used instead, we would translate the arguments into
  echo '$PATH'
and thus print the literal $PATH string.

I don't think it's really worth the risk at this point (and this request is a few years old anyway), so I'm closing it now.  There surely is a way (yet a bit hacky, admittedly) to achieve the desired result, by escaping the double quotes like this:

  # scl enable <collection> -- echo '[\"hello\"]'
  ["hello"]


Note You need to log in before you can comment on or make changes to this bug.