Galaxie Shell 0.2.6 documentation


Navigation:   | Index   | Search   | Top   | Up   |
Table of Content: |

© Copyright 2020-2024, Galaxie Shell Team.

Top » Module code » glxshell.utilities.unalias

Source code for glxshell.utilities.unalias

import sys
from glxshell.lib.argparse import ArgumentParser


parser_unalias = ArgumentParser(
    name="unalias - remove alias definitions",
    description="The unalias utility shall remove the definition for each alias name specified.",
    synopsis=["unalias alias-name..."],
    exit_status={
        "0": "Successful completion.",
        ">0": "One of the alias-name operands specified did not represent a valid alias definition, or an "
              "error occurred."
    },
)

parser_unalias.add_argument(
    "-a",
    dest="a",
    action="store_true",
    help="Remove all alias definitions from the current shell execution environment.",
)

parser_unalias.add_argument(
    "alias-name",
    dest="alias_name",
    nargs="*",
    type=str,
    help="The name of an alias to be removed.",
)


[docs] def glxsh_unalias(a=None, alias_name=None, shell=None): """ The unalias utility shall remove the definition for each alias name specified. See Alias Substitution. The aliases shall be removed from the current shell execution environment; see Shell Execution Environment. :param string: every argument after alias cmg as a single string :type string: str """ exit_code = 0 try: if a: shell.alias = {} else: for alias in alias_name: if alias in shell.alias: del shell.alias[alias] else: exit_code += 1 return exit_code except (Exception, BaseException) as error: # pragma: no cover sys.stderr.write("alias: %s\n" % error) return 1

Top » Module code » glxshell.utilities.unalias

© Copyright 2020-2024, Galaxie Shell Team.
This page is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Public License (CC BY-NC-SA 4.0).
Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
See History and License for more information.

Last updated on None.
Created using Sphinx 8.0.2.