{"action":"created","issue":{"url":"https://api.github.com/repos/PhrozenByte/rmtrash/issues/2","labels_url":"https://api.github.com/repos/PhrozenByte/rmtrash/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/PhrozenByte/rmtrash/issues/2/comments","events_url":"https://api.github.com/repos/PhrozenByte/rmtrash/issues/2/events","html_url":"https://github.com/PhrozenByte/rmtrash/issues/2","id":108097820,"number":2,"title":"alias rm, does not work in scripts","user":{"login":"nicesw123","id":7419913,"avatar_url":"https://avatars.githubusercontent.com/u/7419913?v=3","gravatar_id":"","url":"https://api.github.com/users/nicesw123","html_url":"https://github.com/nicesw123","followers_url":"https://api.github.com/users/nicesw123/followers","following_url":"https://api.github.com/users/nicesw123/following{/other_user}","gists_url":"https://api.github.com/users/nicesw123/gists{/gist_id}","starred_url":"https://api.github.com/users/nicesw123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicesw123/subscriptions","organizations_url":"https://api.github.com/users/nicesw123/orgs","repos_url":"https://api.github.com/users/nicesw123/repos","events_url":"https://api.github.com/users/nicesw123/events{/privacy}","received_events_url":"https://api.github.com/users/nicesw123/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-09-24T09:56:54Z","updated_at":"2015-09-24T12:40:36Z","closed_at":null,"body":"Hi,\r\n\r\nthanks for this nice wrapper of trash_cli.\r\n\r\nBut alias definitions do not work in scripts. Example...\r\n\r\nUsing \r\n```bash\r\nalias rm='rmtrash'\r\nalias rmdir='rmdirtrash'\r\nalias sudo='sudo '\r\n```\r\n\r\nwill not work in a script such as \r\n* **`myscript.sh`**\r\n ```bash\r\n#!/usr/bin/env bash\r\n\r\nrm testfile.txt\r\n```\r\n\r\n#### Possible solution\r\n\r\nPut a script-version of `rm` and `rmdir` into `/usr/local/bin` as follows:\r\n* **`/usr/local/bin/rm`**\r\n ```bash\r\n#!/usr/bin/env bash\r\n\r\n/usr/local/bin/rmtrash \"$@\"\r\n```\r\n\r\n* **`/usr/local/bin/rmdir`**\r\n ```bash\r\n#!/usr/bin/env bash\r\n\r\n/usr/local/bin/rmdirtrash \"$@\"\r\n```\r\n\r\n(Needs `rmtrash` and `rmdirtrash` in `/usr/local/bin`.)\r\n\r\nThen **important !!**\r\n\r\n* Change [`rmtrash` line 186](https://github.com/PhrozenByte/rmtrash/blob/b4c46157ad5c90a5fb9e6e109e67b06a254c0709/rmtrash#L186) to\r\n ```bash\r\nPATH=/usr/bin:/bin   RM_CMD=\"$(which \"rm\")\"\r\n```\r\n\r\n* Change [`rmdirtrash` line 161](https://github.com/PhrozenByte/rmtrash/blob/b4c46157ad5c90a5fb9e6e109e67b06a254c0709/rmdirtrash#L161) to\r\n ```bash\r\nPATH=/usr/bin:/bin   RM_CMD=\"$(which \"rmdir\")\"\r\n```\r\n\r\nFrom [bash manual section 3.7.4](http://www.gnu.org/software/bash/manual/bash.html#Environment): *\"The environment for any simple command or function may be augmented temporarily by prefixing it with parameter assignments, as described in Shell Parameters. These assignment statements affect only the environment seen by that command. \"*\r\n\r\nSo this finds the standard `rm` and `rmdir` which is what we want.\r\n(This is also a solution, for your warning ([link](https://github.com/PhrozenByte/rmtrash/commit/1880753f717dba5815ab8ed9a6431f2e75ed068a#diff-04c6e90faac2675aa89e2176d2eec7d8R72)) about: *\" Never name ```rmtrash```s scriptfile ```rm``` - this will replace ```rm``` and is definitly not what you actually want!\"*)\r\n\r\nWhat do you think?\r\n\r\nOh some questions:\r\n* Is there any other way you know, of making `rm` in scripts (`myscript.sh`) work with `rmtrash` ? (I think aliases just don't work).\r\n* Will you consider to change [`rmtrash` line 186](https://github.com/PhrozenByte/rmtrash/blob/b4c46157ad5c90a5fb9e6e109e67b06a254c0709/rmtrash#L186) and [`rmdirtrash` line 161](https://github.com/PhrozenByte/rmtrash/blob/b4c46157ad5c90a5fb9e6e109e67b06a254c0709/rmdirtrash#L161) as shown above?\r\n\r\nThanks."},"comment":{"url":"https://api.github.com/repos/PhrozenByte/rmtrash/issues/comments/142916622","html_url":"https://github.com/PhrozenByte/rmtrash/issues/2#issuecomment-142916622","issue_url":"https://api.github.com/repos/PhrozenByte/rmtrash/issues/2","id":142916622,"user":{"login":"nicesw123","id":7419913,"avatar_url":"https://avatars.githubusercontent.com/u/7419913?v=3","gravatar_id":"","url":"https://api.github.com/users/nicesw123","html_url":"https://github.com/nicesw123","followers_url":"https://api.github.com/users/nicesw123/followers","following_url":"https://api.github.com/users/nicesw123/following{/other_user}","gists_url":"https://api.github.com/users/nicesw123/gists{/gist_id}","starred_url":"https://api.github.com/users/nicesw123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicesw123/subscriptions","organizations_url":"https://api.github.com/users/nicesw123/orgs","repos_url":"https://api.github.com/users/nicesw123/repos","events_url":"https://api.github.com/users/nicesw123/events{/privacy}","received_events_url":"https://api.github.com/users/nicesw123/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T12:40:36Z","updated_at":"2015-09-24T12:40:36Z","body":"Damn I wrote too quickly...\r\n\r\nThe following...\r\n> * **`/usr/local/bin/rm`**\r\n> ```bash\r\n#!/usr/bin/env bash\r\nPATH=/usr/bin:/bin   /usr/local/bin/rmtrash \"$@\"\r\n```\r\n\r\n... does not work as I intended.\r\nFor some strange reason, the PATH I want to pass in, `PATH=/usr/bin:/bin` is ignored.\r\nI don't (yet) know why..."}}