gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master 90f08c2 53/62: Auto-completion: Refactor ..._i


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 90f08c2 53/62: Auto-completion: Refactor ..._is_table function
Date: Thu, 13 May 2021 22:20:54 -0400 (EDT)

branch: master
commit 90f08c2d8c4e659551170e55acd4e1311348ecbf
Author: Pedram Ashofteh Ardakani <pedramardakani@pm.me>
Commit: Mohammad Akhlaghi <mohammad@akhlaghi.org>

    Auto-completion: Refactor ..._is_table function
    
    With this commit, I replaced 'return 0' (or 1) with 'break' as it used to
    be. Because we are not using the function as a boolean query. However, we
    can se if there is a valid FITS or plaintext file withing the command
    line by checking if the $last_table is populated: [ x$last_table != x ]
    
    Also, I replaced an indented 'if' with 'elif' for better code readablity.
---
 bin/table/completion.bash | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/bin/table/completion.bash b/bin/table/completion.bash
index 472549f..3298488 100644
--- a/bin/table/completion.bash
+++ b/bin/table/completion.bash
@@ -259,7 +259,7 @@ _gnuastro_autocomplete_is_plaintext_table(){
 
 # Reverse the list of existing strings on the command-line (so the last
 # word becomes the first), then check if it is an acceptable Table file in
-# there.
+# there. This covers FITS and plaintext files so far.
 _gnuastro_autocomplete_last_table(){
 
     # Output variables.
@@ -299,19 +299,14 @@ _gnuastro_autocomplete_last_table(){
                 # break out of the loop that parses the tokens.
                 if $_gnuastro_asttable $token -h$last_table_hdu -i &> 
/dev/null; then
                     last_table="$token"
-                    return 0
+                    break;
                 fi
 
-            # Not a FITS file.
-            else
-                if _gnuastro_autocomplete_is_plaintext_table $token; then
-                    last_table="$token"
-                    return 0
-                fi
+            # Not a FITS file, check if it is a plaintext table.
+            elif _gnuastro_autocomplete_is_plaintext_table $token; then
+                last_table="$token"
+                break;
             fi
-        else
-            # The file $token does not exist
-            return 1
         fi
     done
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]