Summary: | ASTERISK-22985: System() doesn't handle echo -e like it should | ||
Reporter: | Pierre (Anodyne) | Labels: | |
Date Opened: | 2013-12-13 12:44:36.000-0600 | Date Closed: | 2013-12-13 13:14:41.000-0600 |
Priority: | Major | Regression? | Yes |
Status: | Closed/Complete | Components: | Applications/app_system |
Versions: | 10.8.0 11.6.0 | Frequency of Occurrence | Constant |
Related Issues: | |||
Environment: | Debian 7.2 32bits | Attachments: | |
Description: | 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. | ||
Comments: | By: Rusty Newton (rnewton) 2013-12-13 13:13:57.725-0600 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. |