[asterisk-bugs] [JIRA] (ASTERISK-22985) System() doesn't handle echo -e like it should

Rusty Newton (JIRA) noreply at issues.asterisk.org
Fri Dec 13 13:17:03 CST 2013


    [ https://issues.asterisk.org/jira/browse/ASTERISK-22985?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=212920#comment-212920 ] 

Rusty Newton edited comment on ASTERISK-22985 at 12/13/13 1:16 PM:
-------------------------------------------------------------------

I talked with a few people and found that this would be safer when using echo:

{code}
System(/bin/echo -e 'my first line\\nMy second line' > /tmp/atestfile)
{code}

And as Walter Doekes mentioned in chat, using printf would be more portable:

{code}
System(printf 'my first line\nMy second line\n' > /tmp/atestfile)
{code}

{quote}
<wdoekes> when you did echo (without bin) you got the builtin shell command
<wdoekes> and you apparently got a new default shell (dash instead of bash, perhaps)
<wdoekes> and the builtins differ in behaviour, as does the /bin/echo implementation accross distribution
{quote}

If behavior changed over time, it was likely due to a system update affecting shell versions or which shells are used.
                
      was (Author: rnewton):
    I talked with a few people and found that this would be safer when using echo:

{code}
System(/bin/echo -e 'my first line\\nMy second line' > /tmp/atestfile)
{code}

And as Walter Doekes mentioned in chat, using printf be more portable:

{code}
System(printf 'my first line\nMy second line\n' > /tmp/atestfile)
{code}

{quote}
<wdoekes> when you did echo (without bin) you got the builtin shell command
<wdoekes> and you apparently got a new default shell (dash instead of bash, perhaps)
<wdoekes> and the builtins differ in behaviour, as does the /bin/echo implementation accross distribution
{quote}

If behavior changed over time, it was likely due to a system update affecting shell versions or which shells are used.
                  
> System() doesn't handle echo -e like it should
> ----------------------------------------------
>
>                 Key: ASTERISK-22985
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-22985
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Applications/app_system
>    Affects Versions: 10.8.0, 11.6.0
>         Environment: Debian 7.2 32bits
>            Reporter: Pierre
>
> The following dialplan snippet
> {code:title=extensions.conf|borderStyle=solid}
> same => n(setupCallback),System(echo -e "Channel: SIP/${paidTrunkPrefix}${trunkUser}/${routeType}${CALLERID(num)}\\nCallerID: \"Callback\" <155551234>\\nMaxRetries: 2\\nRetryTime: 10\\nWaitTime: 15\\nContext: CallbackAnswer\\nExtension: ${trunkUser}\\nPriority: 1" > /tmp/callback.call)
> {code}
> doesn't behave like expected. The "-e" is output to the .call file resulting in an invalid syntax for a .call file. The line return and escaped quotes are parsed as they should, the only issue is that the "-e" argument is inserted at the beginning of the .call file
> If I run the exact same command in the shell, it does what is expected: line returns parsed etc without inserting the "-e" argument in the output file.
> I did not have this problem using Asterisk 11.2.1. I talked about it on IRC, a user tried with the latest SVN of 11 and had the same problem.
> *** WORKAROUND FOUND ***
> Thanks to user newtonr on the IRC, replacing echo by /bin/echo fixes it. I'll leave it up to the devs to figure out if this is intentional or not.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.asterisk.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the asterisk-bugs mailing list