When i run the script:
#!/bin/bash DRUPAL_ROOT=$(drush status root --format=list) if [ -z $DRUPAL_ROOT ] then echo -e "Not exists Drupal core" else echo $DRUPAL_ROOT cd $DRUPAL_ROOT fi Output:
# /right/drupal/root But no change to path
If i run commands in terminal:
# DRUPAL_ROOT=$(drush status root --format=list) # cd $DRUPAL_ROOT Change OK
Any idea? Thanks.
cdinto the directory, and then terminate, leaving you in the shell (and working directory) in which you invoked the script, not the script's final working dorectory. This can be shown by adding apwdline after thecdcommand.