Jira (PUP-6524) The shell used with exec resource provider=shell should be configurable

3 views
Skip to first unread message

Adam Bottchen (JIRA)

unread,
Jul 19, 2016, 9:40:13 PM7/19/16
to puppe...@googlegroups.com
Adam Bottchen moved an issue
 
Puppet / New Feature PUP-6524
The shell used with exec resource provider=shell should be configurable
Change By: Adam Bottchen
Component/s: puppet
Component/s: Client
Key: PE PUP - 14558 6524
Project: Puppet  Enterprise [Internal]
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

Adam Bottchen (JIRA)

unread,
Jul 19, 2016, 9:41:04 PM7/19/16
to puppe...@googlegroups.com
Adam Bottchen updated an issue
Change By: Adam Bottchen
Sprint: Client Triage
Scrum Team: Client Platform

Adam Bottchen (JIRA)

unread,
Aug 1, 2016, 8:51:05 PM8/1/16
to puppe...@googlegroups.com
Adam Bottchen updated an issue
Customer found that when creating an exec resource, they are unable to run commands with bash  builtins  process substitions .  For example:

{code:java}
class exectest {
  exec{'run if different':
    provider => 'shell',
    command => '/bin/echo "they are different" > test.log',
    onlyif => "/usr/bin/test `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c` -gt 0",
  }
}
{code}

will fail to parse:

{code:java}
# puppet apply -td -e "include exectest"
...
Debug: Exec[run if different](provider=shell): Executing check '["/bin/sh", "-c", "/usr/bin/test `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c` -gt 0"]'
Debug: Executing '/bin/sh -c /usr/bin/test `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c` -gt 0'
Debug: /Stage[main]/Exectest/Exec[run if different]/onlyif: /bin/sh: command substitution: line 0: syntax error near unexpected token `('
Debug: /Stage[main]/Exectest/Exec[run if different]/onlyif: /bin/sh: command substitution: line 0: `/usr/bin/diff <(printf 'abc') <(printf 'xyz') | grep '' -c'
Debug: /Stage[main]/Exectest/Exec[run if different]/onlyif: /usr/bin/test: missing argument after `0'
...
{code}

This is due to the fact that https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/exec/shell.rb#L19 forces the /bin/sh shell, which cannot parse the bash
 builtins  process substitutions .  This is true even on EL systems where /bin/sh is linked to /bin/bash.

Customer would like to see the shell used by provider=shell be configurable instead of hardcoded to avoid this issue.

Kenn Hussey (JIRA)

unread,
Sep 29, 2016, 3:00:16 PM9/29/16
to puppe...@googlegroups.com
Kenn Hussey updated an issue
Change By: Kenn Hussey
Sprint: Client Triage
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Kenn Hussey (JIRA)

unread,
Sep 29, 2016, 3:00:23 PM9/29/16
to puppe...@googlegroups.com

Kenn Hussey (JIRA)

unread,
Sep 29, 2016, 3:01:17 PM9/29/16
to puppe...@googlegroups.com

Kenn Hussey (JIRA)

unread,
Sep 29, 2016, 3:01:23 PM9/29/16
to puppe...@googlegroups.com

Kenn Hussey (JIRA)

unread,
Sep 29, 2016, 4:01:06 PM9/29/16
to puppe...@googlegroups.com

Moses Mendoza (JIRA)

unread,
Oct 3, 2016, 5:46:03 PM10/3/16
to puppe...@googlegroups.com

Geoff Nichols (JIRA)

unread,
Oct 6, 2016, 5:31:03 PM10/6/16
to puppe...@googlegroups.com

Eric Thompson (JIRA)

unread,
Oct 7, 2016, 3:28:02 PM10/7/16
to puppe...@googlegroups.com

Geoff Nichols (JIRA)

unread,
Oct 13, 2016, 1:25:05 PM10/13/16
to puppe...@googlegroups.com
Geoff Nichols updated an issue
Change By: Geoff Nichols
Component/s: Client
Component/s: Types and Providers

Joe Pinsonault (JIRA)

unread,
May 16, 2017, 3:15:04 PM5/16/17
to puppe...@googlegroups.com

Daryl Cashville (Jira)

unread,
Sep 29, 2022, 11:54:02 PM9/29/22
to puppe...@googlegroups.com
Daryl Cashville commented on New Feature PUP-6524
 
Re: The shell used with exec resource provider=shell should be configurable

This was at the root of my issue reported in PA-4649 - Ubuntu uses 'dash' by default which doesn't support 'bash' keywords, operators, etc.

It would be nice to be able to specify "provider => '/bin/bash'" or some other attribute to allow all of the exec functions that use shell commands to be consistent in syntax. Right now we have to maintain multiple ugly workarounds for Ubuntu.

This message was sent by Atlassian Jira (v8.20.11#820011-sha1:0629dd8)
Atlassian logo

Dirk Heinrichs (Jira)

unread,
Nov 29, 2022, 3:52:02 AM11/29/22
to puppe...@googlegroups.com

I wonder why this hasn't been implemented in 6(!!!) years. It's a matter of simply copying lib/puppet/provider/exec/shell.rb to lib/puppet/provider/exec/bash.rb, change its name from ":shell" to ":bash" on line 1 and every occurrence of "/bin/sh" (Hint: there are exactly two of them) to "/bin/bash".

Two minutes, problem solved. So, please, just do it.

Reply all
Reply to author
Forward
0 new messages