Command line path arguments need the current directory
| Project: | Drush |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
I want to use a command line file path with Drush (see #185373: Review code snippets). Since drush is a command line tool, this seems like a reasonable thing to do. Currently, drush does a chdir(), and all paths are relative to the Drupal root. However, I am running drush from one of my sites directories, and the path should be DRUPAL_ROOT/sites/example.com/. There are options to figuring out what file a user intended to use... such as getting the conf_path() and looking for it relative to that one. But since the current working directory is so pivotal to figuring out a file path, and since Drush is a command line tool, I was thinking that it made sense to just save this variable for anyone that wanted to use it.
Does it make sense to store the CWD before changing it?
| Attachment | Size |
|---|---|
| oldpwd.patch | 612 bytes |

#1
#2
OK. I think CWD is more consistent than PWD and I would even prefix so it is DRUSH_OLDCWD.
#3
I used OLDPWD, because that's what the shell uses, but here's a patch using DRUPAL_OLDCWD.
#4
Committed a slightly different fix. Get the value using drupal_get_context('DRUSH_OLDCWD').
#5
Automatically closed -- issue fixed for 2 weeks with no activity.