Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • While I think this is clever it seems it is dangerous since it relies on .bashrc. (This won't work for cron, for instance).
    – ctbrown
    Commented Dec 21, 2017 at 17:30
  • 1
    I'm not sure there is anything dangerous about bashrc. I believe that this is the standard/correct place for aliases. It is in the nature of environments that they are different. Give the question, a different environment is what is required. Nothing to stop you sourcing a users .bashrc in cron if you want cron to have a similar environment. N.B. cron should always be expected to behave differently to an interactive shell due to use of isatty and chums.
    – teknopaul
    Commented Dec 23, 2017 at 22:52
  • True, there is nothing dangerous about bashrc itself. The problem is that you have no way of ensuring that the process that is changing to directory will source bashrc. It is one thing if it is your interactive session. It is quite another if that directory is shared among users and processes which may or may not use the bash shell. .bash_aliases is the preferred location for bash aliases on some systems.
    – ctbrown
    Commented Dec 25, 2017 at 15:55