Skip to content
Snippets Groups Projects
Commit 5a78e2e7 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Handle more errors in bash completion


Don't print error messages if cluster hasn't been initialized yet.

Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent d763bed0
No related branches found
No related tags found
No related merge requests found
...@@ -85,7 +85,7 @@ def WritePreamble(sw): ...@@ -85,7 +85,7 @@ def WritePreamble(sw):
sw.IncIndent() sw.IncIndent()
try: try:
node_list_path = os.path.join(constants.DATA_DIR, "ssconf_node_list") node_list_path = os.path.join(constants.DATA_DIR, "ssconf_node_list")
sw.Write("cat %s", utils.ShellQuote(node_list_path)) sw.Write("cat %s 2>/dev/null || :", utils.ShellQuote(node_list_path))
finally: finally:
sw.DecIndent() sw.DecIndent()
sw.Write("}") sw.Write("}")
...@@ -95,7 +95,7 @@ def WritePreamble(sw): ...@@ -95,7 +95,7 @@ def WritePreamble(sw):
try: try:
instance_list_path = os.path.join(constants.DATA_DIR, instance_list_path = os.path.join(constants.DATA_DIR,
"ssconf_instance_list") "ssconf_instance_list")
sw.Write("cat %s", utils.ShellQuote(instance_list_path)) sw.Write("cat %s 2>/dev/null || :", utils.ShellQuote(instance_list_path))
finally: finally:
sw.DecIndent() sw.DecIndent()
sw.Write("}") sw.Write("}")
...@@ -104,9 +104,10 @@ def WritePreamble(sw): ...@@ -104,9 +104,10 @@ def WritePreamble(sw):
sw.IncIndent() sw.IncIndent()
try: try:
# FIXME: this is really going into the internals of the job queue # FIXME: this is really going into the internals of the job queue
sw.Write("local jlist=$( cd %s && echo job-*; )", sw.Write(("local jlist=$( shopt -s nullglob &&"
" cd %s 2>/dev/null && echo job-* || : )"),
utils.ShellQuote(constants.QUEUE_DIR)) utils.ShellQuote(constants.QUEUE_DIR))
sw.Write("echo ${jlist//job-/}") sw.Write('echo "${jlist//job-/}"')
finally: finally:
sw.DecIndent() sw.DecIndent()
sw.Write("}") sw.Write("}")
...@@ -116,7 +117,8 @@ def WritePreamble(sw): ...@@ -116,7 +117,8 @@ def WritePreamble(sw):
try: try:
# FIXME: Make querying the master for all OSes cheap # FIXME: Make querying the master for all OSes cheap
for path in constants.OS_SEARCH_PATH: for path in constants.OS_SEARCH_PATH:
sw.Write("( cd %s && echo *; )", utils.ShellQuote(path)) sw.Write("( shopt -s nullglob && cd %s 2>/dev/null && echo * || : )",
utils.ShellQuote(path))
finally: finally:
sw.DecIndent() sw.DecIndent()
sw.Write("}") sw.Write("}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment