This is an automated email from the ASF dual-hosted git repository.

yangjie01 pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 3573f81a545e [SPARK-53149][CORE] Fix testing whether BeeLine process 
run in background
3573f81a545e is described below

commit 3573f81a545efa2cc1474173b327bcd1f370ade2
Author: Cheng Pan <[email protected]>
AuthorDate: Fri Oct 17 15:14:45 2025 +0800

    [SPARK-53149][CORE] Fix testing whether BeeLine process run in background
    
    ### What changes were proposed in this pull request?
    
    I found that BeeLine does not work well with the arrow keys, for example, 
when I push `up`, `down`, `left`, `right` keys, I see
    
    ```
    $ spark-4.0.0-bin-hadoop3/bin/beeline
    Beeline version 2.3.10 by Apache Hive
    beeline> ^[[A^[[B^[[D^[[C
    ```
    
    This is because of SPARK-50416, which wrongly expressed the intention of 
SPARK-8731.
    
    Brief history:
    
    SPARK-8731 (3.4.0)
    ```shell
    if [[ ( ! $(ps -o stat= -p $$) =~ "+" ) && ! ( -p /dev/stdin ) ]]; then
      export SPARK_BEELINE_OPTS="$SPARK_BEELINE_OPTS 
-Djline.terminal=jline.UnsupportedTerminal"
    fi
    ```
    
    SPARK-50416 (3.5.6, 4.0.0 start to be broken)
    ```shell
    if [ -e /usr/bin/tty -a "`tty`" != "not a tty" -a ! -p /dev/stdin ]; then
      export SPARK_BEELINE_OPTS="$SPARK_BEELINE_OPTS 
-Djline.terminal=jline.UnsupportedTerminal"
    fi
    ```
    
    SPARK-53149 (this PR, the idea comes from the original author of 
SPARK-50416, but it seems his GitHub account was deleted, so all his PR links 
are inaccessible)
    ```shell
    if [[ ( ! $(ps -o stat= -p $$ 2>/dev/null) =~ "+" ) && ! ( -p /dev/stdin ) 
]]; then
      export SPARK_BEELINE_OPTS="$SPARK_BEELINE_OPTS 
-Djline.terminal=jline.UnsupportedTerminal"
    fi
    ```
    
    ### Why are the changes needed?
    
    Fix regression.
    
    ### Does this PR introduce _any_ user-facing change?
    
    Yes, restore the user experience of BeeLine.
    
    ### How was this patch tested?
    
    I don't have a Windows environment to test WSL and Cygwin cases, I verified 
it on Linux and macOS, BeeLine works as expected with arrow keys.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #52640 from pan3793/SPARK-53149.
    
    Authored-by: Cheng Pan <[email protected]>
    Signed-off-by: yangjie01 <[email protected]>
    (cherry picked from commit d799aa7354b0028190c4fce8b63a503172e9076f)
    Signed-off-by: yangjie01 <[email protected]>
---
 bin/load-spark-env.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/load-spark-env.sh b/bin/load-spark-env.sh
index 4ab35ad28751..8db58ad387e8 100644
--- a/bin/load-spark-env.sh
+++ b/bin/load-spark-env.sh
@@ -65,6 +65,6 @@ export SPARK_SCALA_VERSION=2.13
 #fi
 
 # Append jline option to enable the Beeline process to run in background.
-if [ -e /usr/bin/tty -a "`tty`" != "not a tty" -a ! -p /dev/stdin ]; then
+if [[ ( ! $(ps -o stat= -p $$ 2>/dev/null) =~ "+" ) && ! ( -p /dev/stdin ) ]]; 
then
   export SPARK_BEELINE_OPTS="$SPARK_BEELINE_OPTS 
-Djline.terminal=jline.UnsupportedTerminal"
 fi


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

Reply via email to