Search code examples
bashandroid-source

What does the command "PWD=/proc/self/cwd another_executable " mean?


When building AOSP 9.0.0_r30 source with these commands:

$ make clean
$ make showcommands -j8 > ~/BuildAndroid.txt

there are commands line like this in ~/BuildAndoird.txt:

[ 58% 62374/106553] PWD=/proc/self/cwd prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++ ........

I suppose this is a bash command,but why there is "PWD=/proc/self/cwd" and a space(not ; or &&) before "prebuilts/clang/host/linux-x86/clang-4691093/bin/clang++"?What does this mean,I don't think it is legal for bash because space means the following text are parameters instead of command.

Another problem is,what is "/proc/self/cwd",is that a standard proc node?

Some experiment:

$ VAR=123
$ VAR=456 echo $VAR
 123
$ echo $VAR
 123

So this is really legal,but what is the meaning?


Solution

  • Try again:

    VAR=123
    VAR=456 echo $VAR
    123
    

    Ok, but:

    VAR=456 /bin/sh -c 'echo $VAR'
    456
    

    POSIX variable $PWD

    $PWD will point to current directory

    echo $PWD; ls -l /proc/self/cwd
    /home/user
    lrwxrwxrwx 1 user user 0 mar 26 09:18 /proc/self/cwd -> /home/user
    

    Doing so will ensure $PWD to be set, as android don't require them at all.