summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2018-04-02 15:57:28 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2018-04-02 15:57:28 -0400
commit299c6ea19923b4ab16403e8b67fee96690966348 (patch)
tree80af7c5512469619302deac12dc84fa75b560537 /cmd2.py
parent880bdd1e33f6a11d441ae287cb062c7e72984d81 (diff)
downloadcmd2-git-299c6ea19923b4ab16403e8b67fee96690966348.tar.gz
Don't try to load empty or non-existent startup script
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/cmd2.py b/cmd2.py
index 0e2e9c36..9aa8b5b3 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1052,7 +1052,9 @@ class Cmd(cmd.Cmd):
# If a startup script is provided, then add it in the queue to load
if startup_script is not None:
- self.cmdqueue.append('load {}'.format(startup_script))
+ startup_script = os.path.expanduser(startup_script)
+ if os.path.exists(startup_script) and os.path.getsize(startup_script) > 0:
+ self.cmdqueue.append('load {}'.format(startup_script))
############################################################################################################
# The following variables are used by tab-completion functions. They are reset each time complete() is run
@@ -2747,8 +2749,8 @@ class Cmd(cmd.Cmd):
Usage: Usage: alias [name] | [<name> <value>]
Where:
- name - name of the alias being looked up, added, or edited
- value - what the alias will be resolved to (if adding or editing)
+ name - name of the alias being looked up, added, or replaced
+ value - what the alias will be resolved to (if adding or replacing)
this can contain spaces and does not need to be quoted
Without arguments, 'alias' prints a list of all aliases in a reusable form which
@@ -2780,7 +2782,7 @@ Usage: Usage: alias [name] | [<name> <value>]
if name in self.aliases:
self.poutput("alias {} {}".format(name, self.aliases[name]))
else:
- self.perror("Alias '{}' not found".format(name), traceback_war=False)
+ self.perror("Alias {!r} not found".format(name), traceback_war=False)
# The user is creating an alias
else:
@@ -2796,7 +2798,7 @@ Usage: Usage: alias [name] | [<name> <value>]
# Set the alias
self.aliases[name] = value
- self.poutput("Alias created")
+ self.poutput("Alias {!r} created".format(name))
def complete_alias(self, text, line, begidx, endidx):
""" Tab completion for alias """