I'm trying to add something to my shell that shows the current Drupal root value so that we can use drush use more, but the only way I can see to return the current Drupal root value is to run drush status which is quite slow
On the old system I'm on right now, that clocks in at 3.5s, vs. 11.8s for
If you are using site aliases, as tenken suggested, then you can do this:
Sure. Instead of running
The simplest example from that documentation file is:
You basically are hardcoding the filepaths. You can later use this known structure and data to lookup the site root paths when you need them.
If you want to automate building your site alias file you can look at this example tutorial (I am not the author) called Drush Pro Tips: Automatic Site Aliases by Rob at LastCallMedia. His example uses the following code to build an alias file across a structured project codebase:
Once you have a site alias file you can then use BASH commands to easily rip out the information from the alias array or show it to the screen. This approved answer from our own site on showing site alias information is an example of utilizing BASH to get at the alias information http://drupal.stackexchange.com/a/50563/3279
The final example shows how to show the site paths on the filesystem from the answer, you could further tweak his BASH commands into an alias that just returns the raw
In Drupal 7 you can just print
which obviously won't be faster than
So to make it quicker, you need to use something else than Drush.
For example if your Drupal is under git repository, quicker solution for the script is to check top dir of your repository, e.g.
To look for the first folder containing