Command line path arguments need the current directory

douggreen - August 20, 2008 - 12:38
Project:Drush
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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?

AttachmentSize
oldpwd.patch612 bytes

#1

douggreen - August 20, 2008 - 18:10
Title:Allow command line partial path arguments by storing the directory» Command line path arguments need the current directory

#2

moshe weitzman - August 21, 2008 - 02:41
Status:needs review» reviewed & tested by the community

OK. I think CWD is more consistent than PWD and I would even prefix so it is DRUSH_OLDCWD.

#3

douggreen - August 21, 2008 - 11:02

I used OLDPWD, because that's what the shell uses, but here's a patch using DRUPAL_OLDCWD.

AttachmentSize
297611.patch 575 bytes

#4

moshe weitzman - September 21, 2009 - 01:37
Status:reviewed & tested by the community» fixed

Committed a slightly different fix. Get the value using drupal_get_context('DRUSH_OLDCWD').

#5

System Message - October 5, 2009 - 01:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.