{"action":"created","issue":{"url":"https://api.github.com/repos/Winetricks/winetricks/issues/697","repository_url":"https://api.github.com/repos/Winetricks/winetricks","labels_url":"https://api.github.com/repos/Winetricks/winetricks/issues/697/labels{/name}","comments_url":"https://api.github.com/repos/Winetricks/winetricks/issues/697/comments","events_url":"https://api.github.com/repos/Winetricks/winetricks/issues/697/events","html_url":"https://github.com/Winetricks/winetricks/issues/697","id":190075022,"number":697,"title":"tmp.ahk gets corrupted by \\r characters (OSX/BSD sed)","user":{"login":"kenorb","id":266306,"avatar_url":"https://avatars.githubusercontent.com/u/266306?v=3","gravatar_id":"","url":"https://api.github.com/users/kenorb","html_url":"https://github.com/kenorb","followers_url":"https://api.github.com/users/kenorb/followers","following_url":"https://api.github.com/users/kenorb/following{/other_user}","gists_url":"https://api.github.com/users/kenorb/gists{/gist_id}","starred_url":"https://api.github.com/users/kenorb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kenorb/subscriptions","organizations_url":"https://api.github.com/users/kenorb/orgs","repos_url":"https://api.github.com/users/kenorb/repos","events_url":"https://api.github.com/users/kenorb/events{/privacy}","received_events_url":"https://api.github.com/users/kenorb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-11-17T15:16:06Z","updated_at":"2016-11-28T08:50:40Z","closed_at":"2016-11-22T08:20:25Z","body":"Reproducible steps (tested on macOS Sierra):\r\n\r\n    sh -xs mt4 < <(wget -qO- https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks)\r\n\r\nThis also happens for me when running in the standard way:\r\n\r\n    winetricks mt4  \r\n\r\nError:\r\n\r\n<img width=\"272\" alt=\"screen shot 2016-11-17 at 15 14 45\" src=\"https://cloud.githubusercontent.com/assets/266306/20394778/a01b5522-acd8-11e6-9dde-2d5a5592cf28.png\">\r\n\r\n```\r\n$ cat ./drive_c/windows/temp/_mt4/tmp.ahk\r\nw_opt_unattended = 0r\r\nr\r\n        Run, mt4setup.exer\r\n        WinWait, MetaTrader 4 Setup, license agreementr\r\n        ControlClick, Button1r\r\n        Sleep 100r\r\n        ControlClick, Button3r\r\n        WinWait, MetaTrader 4 Setup, Installation successfully completedr\r\n        ControlClick, Button4r\r\n        Process, Wait, terminal.exer\r\n        Process, Close, terminal.exer\r\n    r\r\n```\r\n\r\nRelevant trace log:\r\n\r\n```\r\nExecuting cd /Users/username/.cache/winetricks/mt4\r\n+ test -f /Users/username/.cache/winetricks/ahk/AutoHotkey.exe\r\n++ printf '\\\\r'\r\n+ _W_CR='\\r'\r\n+ cat\r\n+ sed 's/$/\\r/'\r\n+ w_try wine 'y:\\ahk\\AutoHotkey.exe' 'C:\\windows\\Temp\\_mt4\\tmp.ahk'\r\n+ export WINEDLLOVERRIDES\r\n+ printf '%s\\n' 'Executing wine y:\\ahk\\AutoHotkey.exe C:\\windows\\Temp\\_mt4\\tmp.ahk'\r\nExecuting wine y:\\ahk\\AutoHotkey.exe C:\\windows\\Temp\\_mt4\\tmp.ahk\r\n+ case \"$1\" in\r\n+ wine 'y:\\ahk\\AutoHotkey.exe' 'C:\\windows\\Temp\\_mt4\\tmp.ahk'\r\n```\r\n\r\nSomehow created `tmp.ahk` file consist weird `r` characters at the end of each line.\r\n\r\n\r\nMost like it's because of BSD `sed`.\r\n```\r\n$ strings $(which sed) | head\r\n$FreeBSD: src/usr.bin/sed/compile.c,v 1.28 2005/08/04 10:05:11 dds Exp $\r\n$FreeBSD: src/usr.bin/sed/main.c,v 1.36 2005/05/10 13:40:50 glebius Exp $\r\n$FreeBSD: src/usr.bin/sed/misc.c,v 1.10 2004/08/09 15:29:41 dds Exp $\r\n$FreeBSD: src/usr.bin/sed/process.c,v 1.39 2005/04/09 14:31:41 stefanf Exp $\r\n```\r\n\r\n---\r\n\r\nThe problem is how the BSD sed handles the substitution of `$`. Here is the difference between GNU sed and BSD sed:\r\n\r\n```\r\n$ _W_CR=$(printf \\\\\\\\r)\r\n$ /usr/bin/sed \"s/\\$/$_W_CR/\" winetricks | tail\r\n            execute_command \"$verb\"r\r\n        doner\r\n        ;;r\r\nr\r\n    esacr\r\nr\r\n    winetricks_stats_reportr\r\nfir\r\nr\r\n# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4r\r\n\r\n$ gsed \"s/\\$/$_W_CR/\" winetricks | tail\r\n            execute_command \"$verb\"\r\n        done\r\n        ;;\r\n\r\n    esac\r\n\r\n    winetricks_stats_report\r\nfi\r\n\r\n# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4\r\n```"},"comment":{"url":"https://api.github.com/repos/Winetricks/winetricks/issues/comments/263214597","html_url":"https://github.com/Winetricks/winetricks/issues/697#issuecomment-263214597","issue_url":"https://api.github.com/repos/Winetricks/winetricks/issues/697","id":263214597,"user":{"login":"austin987","id":464648,"avatar_url":"https://avatars.githubusercontent.com/u/464648?v=3","gravatar_id":"","url":"https://api.github.com/users/austin987","html_url":"https://github.com/austin987","followers_url":"https://api.github.com/users/austin987/followers","following_url":"https://api.github.com/users/austin987/following{/other_user}","gists_url":"https://api.github.com/users/austin987/gists{/gist_id}","starred_url":"https://api.github.com/users/austin987/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/austin987/subscriptions","organizations_url":"https://api.github.com/users/austin987/orgs","repos_url":"https://api.github.com/users/austin987/repos","events_url":"https://api.github.com/users/austin987/events{/privacy}","received_events_url":"https://api.github.com/users/austin987/received_events","type":"User","site_admin":false},"created_at":"2016-11-28T08:50:40Z","updated_at":"2016-11-28T08:50:40Z","body":"ex is vim specific, which isn't portable. sed is _way_ more common :)"}}
{"actor":{"display_login":"austin987"}}