[ 
https://issues.apache.org/jira/browse/HADOOP-14976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16219364#comment-16219364
 ] 

Arpit Agarwal commented on HADOOP-14976:
----------------------------------------

I see, thank you for the clarification.

In this case, the scripts were historically renamed to allow multi-versioning - 
during upgrades for example. Perhaps the 3.0 script rewrite makes it easier to 
do this differently. I can guess why the variable name detection is done this 
way in 3.0 - it allows separating out script-specific logic into the generic 
hadoop-functions.sh which is neat.

For now it's just an unexpected side effect that rename breaks the 
interpretation of shell variables. My first thought was letting script callers 
override HADOOP_SHELL_EXECNAME, so scripts don't initialize it if it's already 
set. One situation where that might break things is when one script invokes and 
we want HADOOP_SHELL_EXECNAME to reflect the callee script. It looks like that 
doesn't happen today though, scripts like hadoop-distcp.sh and 
hadoop-streaming.sh don't rewrite HADOOP_SHELL_EXECNAME.

> Allow overriding HADOOP_SHELL_EXECNAME
> --------------------------------------
>
>                 Key: HADOOP-14976
>                 URL: https://issues.apache.org/jira/browse/HADOOP-14976
>             Project: Hadoop Common
>          Issue Type: Improvement
>            Reporter: Arpit Agarwal
>
> Some Hadoop shell scripts infer their own name using this bit of shell magic:
> {code}
>  18     MYNAME="${BASH_SOURCE-$0}"
>  19     HADOOP_SHELL_EXECNAME="${MYNAME##*/}"
> {code}
> e.g. see the 
> [hdfs|https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/bin/hdfs#L18]
>  script.
> The inferred shell script name is later passed to _hadoop-functions.sh_ which 
> uses it to construct the names of some environment variables. E.g. when 
> invoking _hdfs datanode_, the options variable name is inferred as follows:
> {code}
> # HDFS + DATANODE + OPTS -> HDFS_DATANODE_OPTS
> {code}
> This works well if the calling script name is standard {{hdfs}} or {{yarn}}. 
> If a distribution renames the script to something like foo.bar, , then the 
> variable names will be inferred as {{FOO.BAR_DATANODE_OPTS}}. This is not a 
> valid bash variable name.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to