#wip(cs): Done. Needs and BASH=/usr/bin/bash
BASHOPTS=checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:globasciiranges:globskipdots:histappend:interactive_comments:patsub_replacement:progcomp:promptvars:sourcepath BASH_ALIASES=() BASH_ARGC=([0]="0") BASH_ARGV=() BASH_CMDS=() BASH_COMPLETION_VERSINFO=([0]="2" [1]="11") BASH_LINENO=() BASH_LOADABLES_PATH=/usr/local/lib/bash:/usr/lib/bash:/opt/local/lib/bash:/usr/pkg/lib/bash:/opt/pkg/lib/bash:. BASH_REMATCH=() BASH_SOURCE=() BASH_VERSINFO=([0]="5" [1]="2" [2]="21" [3]="1" [4]="release" [5]="x86_64-pc-linux-gnu") BASH_VERSION='5.2.21(1)-release' COLORTERM=truecolor COLUMNS=272 COMP_WORDBREAKS=$' \t\n"\'><=;|&(:' DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus DEBUGINFOD_URLS='https://debuginfod.ubuntu.com ' DESKTOP_SESSION=gnome DIRSTACK=() DISPLAY=:1 DOTNET_BUNDLE_EXTRACT_BASE_DIR=/home/kyman/.cache/dotnet_bundle_extract EUID=1000 GDMSESSION=gnome GNOME_DESKTOP_SESSION_ID=this-is-deprecated GNOME_KEYRING_CONTROL=/run/user/1000/keyring GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/0a8ab02a_a645_4fb0_8b50_79b274e447f9 GNOME_TERMINAL_SERVICE=:1.170 GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1 GROUPS=() GSM_SKIP_SSH_AGENT_WORKAROUND=true GTK_MODULES=gail:atk-bridge HISTCONTROL=ignoreboth HISTFILE=/home/kyman/.bash_history HISTFILESIZE=2000 HISTSIZE=1000 HOME=/home/kyman HOSTNAME=kyman-GS75-9SE HOSTTYPE=x86_64 IFS=$' \t\n' LANG=es_ES.UTF-8 LESSCLOSE='/usr/bin/lesspipe %s %s' LESSOPEN='| /usr/bin/lesspipe %s' LINES=66 LOGNAME=kyman LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=00:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.avif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:*~=00;90:*#=00;90:*.bak=00;90:*.crdownload=00;90:*.dpkg-dist=00;90:*.dpkg-new=00;90:*.dpkg-old=00;90:*.dpkg-tmp=00;90:*.old=00;90:*.orig=00;90:*.part=00;90:*.rej=00;90:*.rpmnew=00;90:*.rpmorig=00;90:*.rpmsave=00;90:*.swp=00;90:*.tmp=00;90:*.ucf-dist=00;90:*.ucf-new=00;90:*.ucf-old=00;90:' MACHTYPE=x86_64-pc-linux-gnu MAILCHECK=60 MEMORY_PRESSURE_WATCH=/sys/fs/cgroup/user.slice/user-1000.slice/user@1000.service/session.slice/org.gnome.SettingsDaemon.MediaKeys.service/memory.pressure MEMORY_PRESSURE_WRITE=c29tZSAyMDAwMDAgMjAwMDAwMAA= OLDPWD=/media/kyman/SSD2TB/git.lite/ErrorsManager/CSharp OPTERR=1 OPTIND=1 OSTYPE=linux-gnu PATH=/home/kyman/.cargo/bin:/home/kyman/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/kyman/.dotnet/tools PIPESTATUS=([0]="0") PPID=108860 PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' PS2='> ' PS4='+ ' PWD=/media/kyman/SSD2TB/git.lite/ErrorsManager QT_ACCESSIBILITY=1 QT_IM_MODULE=ibus SESSION_MANAGER=local/kyman-GS75-9SE:@/tmp/.ICE-unix/8014,unix/kyman-GS75-9SE:/tmp/.ICE-unix/8014 SHELL=/bin/bash SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor SHLVL=1 SSH_AUTH_SOCK=/run/user/1000/keyring/ssh SYSTEMD_EXEC_PID=8544 TERM=xterm-256color UID=1000 USER=kyman USERNAME=kyman VTE_VERSION=7600 WINDOWPATH=2 XAUTHORITY=/run/user/1000/gdm/Xauthority XDG_CONFIG_DIRS=/etc/xdg/xdg-gnome:/etc/xdg XDG_CURRENT_DESKTOP=GNOME XDG_DATA_DIRS=/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop XDG_MENU_PREFIX=gnome- XDG_RUNTIME_DIR=/run/user/1000 XDG_SESSION_CLASS=user XDG_SESSION_DESKTOP=gnome XDG_SESSION_TYPE=x11 XMODIFIERS=@im=ibus _=. __git_printf_supports_v=yes _backup_glob='@(#*#|*@(~|.@(bak|orig|rej|swp|dpkg*|rpm@(orig|new|save))))' _xspecs=([tex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [freeamp]="!*.@(mp3|og[ag]|pls|m3u)" [gqmpeg]="!*.@(mp3|og[ag]|pls|m3u)" [texi2html]="!*.texi*" [hbpp]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])" [lowriter]="!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm|pdf)" [rpm2cpio]="!*.[rs]pm" [localc]="!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)" [hbrun]="!*.[Hh][Rr][Bb]" [vi]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [latex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [view]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [madplay]="!*.mp3" [compress]="*.Z" [pdfjadetex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [pbunzip2]="!*.?(t)bz?(2)" [lrunzip]="!*.lrz" [gunzip]="!*.@(Z|[gGd]z|t[ag]z)" [oowriter]="!*.@(sxw|stw|sxg|sgl|doc?([mx])|dot?([mx])|rtf|txt|htm|html|?(f)odt|ott|odm|pdf)" [epiphany]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [acroread]="!*.[pf]df" [znew]="*.Z" [kwrite]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [xemacs]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [gview]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [lzfgrep]="!*.@(tlz|lzma)" [lzless]="!*.@(tlz|lzma)" [cdiff]="!*.@(dif?(f)|?(d)patch)?(.@([gx]z|bz2|lzma))" [zipinfo]="!*.@(zip|[aegjswx]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|aab|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz|whl|[Ff][Cc][Ss]td)" [pdflatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [portecle]="!@(*.@(ks|jks|jceks|p12|pfx|bks|ubr|gkr|cer|crt|cert|p7b|pkipath|pem|p10|csr|crl)|cacerts)" [modplugplay]="!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|oct|okt?(a)|p[st]m|s[3t]m|ult|umx|wav|xm)" [lokalize]="!*.po" [lbzcat]="!*.?(t)bz?(2)" [qiv]="!*.@(gif|jp?(e)g|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|svg)" [totem]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))" [ps2pdfwr]="!*.@(?(e)ps|pdf)" [dvitype]="!*.dvi" [unpigz]="!*.@(Z|[gGdz]z|t[ag]z)" [mozilla]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [pdfunite]="!*.pdf" [gpdf]="!*.[pf]df" [texi2dvi]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [bunzip2]="!*.?(t)bz?(2)" [zathura]="!*.@(cb[rz7t]|djv?(u)|?(e)ps|pdf)" [kaffeine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))" [mpg123]="!*.mp3" [lzegrep]="!*.@(tlz|lzma)" [xv]="!*.@(gif|jp?(e)g?(2)|j2[ck]|jp[2f]|tif?(f)|png|p[bgp]m|bmp|x[bp]m|rle|rgb|pcx|fits|pm|?(e)ps)" [xdvi]="!*.@(dvi|DVI)?(.@(gz|Z|bz2))" [xfig]="!*.fig" [xpdf]="!*.@(pdf|fdf)?(.@(gz|GZ|bz2|BZ2|Z))" [oobase]="!*.odb" [xelatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [gharbour]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])" [bzcat]="!*.?(t)bz?(2)" [dragon]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM|iso|ISO)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))" [xanim]="!*.@(mpg|mpeg|avi|mov|qt)" [lualatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [rgview]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [rvim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [xetex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [lomath]="!*.@(sxm|smf|mml|odf)" [zcat]="!*.@(Z|[gGd]z|t[ag]z)" [lynx]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [uncompress]="!*.Z" [xzcat]="!*.@(?(t)xz|tlz|lzma)" [vim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [loimpress]="!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)" [dvipdf]="!*.dvi" [mpg321]="!*.mp3" [jadetex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [lobase]="!*.odb" [epdfview]="!*.pdf" [ps2pdf14]="!*.@(?(e)ps|pdf)" [ps2pdf13]="!*.@(?(e)ps|pdf)" [ps2pdf12]="!*.@(?(e)ps|pdf)" [poedit]="!*.po" [luatex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [kbabel]="!*.po" [bzme]="!*.@(zip|z|gz|tgz)" [dviselect]="!*.dvi" [realplay]="!*.@(rm?(j)|ra?(m)|smi?(l))" [kdvi]="!*.@(dvi|DVI)?(.@(gz|Z|bz2))" [elinks]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [kghostview]="!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))" [gtranslator]="!*.po" [unzip]="!*.@(zip|[aegjswx]ar|exe|pk3|wsz|zargo|xpi|s[tx][cdiw]|sx[gm]|o[dt][tspgfc]|od[bm]|oxt|epub|apk|aab|ipa|do[ct][xm]|p[op]t[mx]|xl[st][xm]|pyz|whl|[Ff][Cc][Ss]td)" [ggv]="!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))" [oomath]="!*.@(sxm|smf|mml|odf)" [dvipdfmx]="!*.dvi" [makeinfo]="!*.texi*" [okular]="!*.@(okular|@(?(e|x)ps|?(E|X)PS|[pf]df|[PF]DF|dvi|DVI|cb[rz]|CB[RZ]|djv?(u)|DJV?(U)|dvi|DVI|gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx|GIF|JP?(E)G|MIFF|TIF?(F)|PN[GM]|P[BGP]M|BMP|XPM|ICO|XWD|TGA|PCX|epub|EPUB|odt|ODT|fb?(2)|FB?(2)|mobi|MOBI|g3|G3|chm|CHM)?(.?(gz|GZ|bz2|BZ2|xz|XZ)))" [sxemacs]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [aviplay]="!*.@(avi|asf|wmv)" [rgvim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [dvipdfm]="!*.dvi" [ly2dvi]="!*.ly" [oodraw]="!*.@(sxd|std|sda|sdd|?(f)odg|otg)" [kpdf]="!*.@(?(e)ps|pdf)" [bibtex]="!*.aux" [netscape]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [emacs]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [rview]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [galeon]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [dillo]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [fbxine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))" [oocalc]="!*.@(sxc|stc|xls?([bmx])|xlw|xlt?([mx])|[ct]sv|?(f)ods|ots)" [harbour]="!*.@([Pp][Rr][Gg]|[Cc][Ll][Pp])" [lodraw]="!*.@(sxd|std|sda|sdd|?(f)odg|otg)" [dvips]="!*.dvi" [ps2pdf]="!*.@(?(e)ps|pdf)" [kate]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [kid3-qt]="!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)" [pdftex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [gvim]="*.@([ao]|so|so.!(conf|*/*)|[rs]pm|gif|jp?(e)g|mp3|mp?(e)g|avi|asf|ogg|class)" [timidity]="!*.@(mid?(i)|rmi|rcp|[gr]36|g18|mod|xm|it|x3m|s[3t]m|kar)" [ogg123]="!*.@(og[ag]|m3u|flac|spx)" [lzgrep]="!*.@(tlz|lzma)" [ee]="!*.@(gif|jp?(e)g|miff|tif?(f)|pn[gm]|p[bgp]m|bmp|xpm|ico|xwd|tga|pcx)" [unlzma]="!*.@(tlz|lzma)" [lbunzip2]="!*.?(t)bz?(2)" [ooimpress]="!*.@(sxi|sti|pps?(x)|ppt?([mx])|pot?([mx])|?(f)odp|otp)" [xine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))" [amaya]="!*.@(?([xX]|[sS])[hH][tT][mM]?([lL]))" [gv]="!*.@(@(?(e)ps|?(E)PS|pdf|PDF)?(.gz|.GZ|.bz2|.BZ2|.Z))" [kid3]="!*.@(mp[234c]|og[ag]|@(fl|a)ac|m4[abp]|spx|tta|w?(a)v|wma|aif?(f)|asf|ape)" [lilypond]="!*.ly" [modplug123]="!*.@(669|abc|am[fs]|d[bs]m|dmf|far|it|mdl|m[eo]d|mid?(i)|mt[2m]|oct|okt?(a)|p[st]m|s[3t]m|ult|umx|wav|xm)" [pbzcat]="!*.?(t)bz?(2)" [unxz]="!*.@(?(t)xz|tlz|lzma)" [playmidi]="!*.@(mid?(i)|cmf)" [lzcat]="!*.@(tlz|lzma)" [slitex]="!*.@(?(la)tex|texi|dtx|ins|ltx|dbj)" [aaxine]="!*@(.@(mp?(e)g|MP?(E)G|wm[av]|WM[AV]|avi|AVI|asf|vob|VOB|bin|dat|divx|DIVX|vcd|ps|pes|fli|flv|FLV|fxm|FXM|viv|rm|ram|yuv|mov|MOV|qt|QT|web[am]|WEB[AM]|mp[234]|MP[234]|m?(p)4[av]|M?(P)4[AV]|mkv|MKV|og[agmvx]|OG[AGMVX]|t[ps]|T[PS]|m2t?(s)|M2T?(S)|mts|MTS|wav|WAV|flac|FLAC|asx|ASX|mng|MNG|srt|m[eo]d|M[EO]D|s[3t]m|S[3T]M|it|IT|xm|XM)|+([0-9]).@(vdr|VDR))?(.@(crdownload|part))" [advi]="!*.dvi" [lzmore]="!*.@(tlz|lzma)" ) __expand_tilde_by_ref () { if [[ ${!1-} == \~* ]]; then eval $1="$(printf ~%q "${!1#\~}")"; fi } __get_cword_at_cursor_by_ref () { local cword words=(); __reassemble_comp_words_by_ref "$1" words cword; local i cur="" index=$COMP_POINT lead=${COMP_LINE:0:COMP_POINT}; if [[ $index -gt 0 && ( -n $lead && -n ${lead//[[:space:]]/} ) ]]; then cur=$COMP_LINE; for ((i = 0; i <= cword; ++i)) do while [[ ${#cur} -ge ${#words[i]} && ${cur:0:${#words[i]}} != "${words[i]-}" ]]; do cur="${cur:1}"; ((index > 0)) && ((index--)); done; if ((i < cword)); then local old_size=${#cur}; cur="${cur#"${words[i]}"}"; local new_size=${#cur}; ((index -= old_size - new_size)); fi; done; [[ -n $cur && ! -n ${cur//[[:space:]]/} ]] && cur=; ((index < 0)) && index=0; fi; local "$2" "$3" "$4" && _upvars -a${#words[@]} $2 ${words+"${words[@]}"} -v $3 "$cword" -v $4 "${cur:0:index}" } __git_eread () { test -r "$1" && IFS=' ' read -r "$2" < "$1" } __git_ps1 () { local exit=$?; local pcmode=no; local detached=no; local ps1pc_start='\u@\h:\w '; local ps1pc_end='\$ '; local printf_format=' (%s)'; case "$#" in 2 | 3) pcmode=yes; ps1pc_start="$1"; ps1pc_end="$2"; printf_format="${3:-$printf_format}"; PS1="$ps1pc_start$ps1pc_end" ;; 0 | 1) printf_format="${1:-$printf_format}" ;; *) return $exit ;; esac; local ps1_expanded=yes; [ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no; [ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no; local repo_info rev_parse_exit_code; repo_info="$(git rev-parse --git-dir --is-inside-git-dir --is-bare-repository --is-inside-work-tree --short HEAD 2> /dev/null)"; rev_parse_exit_code="$?"; if [ -z "$repo_info" ]; then return $exit; fi; local short_sha=""; if [ "$rev_parse_exit_code" = "0" ]; then short_sha="${repo_info##*' '}"; repo_info="${repo_info%' '*}"; fi; local inside_worktree="${repo_info##*' '}"; repo_info="${repo_info%' '*}"; local bare_repo="${repo_info##*' '}"; repo_info="${repo_info%' '*}"; local inside_gitdir="${repo_info##*' '}"; local g="${repo_info%' '*}"; if [ "true" = "$inside_worktree" ] && [ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] && [ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] && git check-ignore -q .; then return $exit; fi; local sparse=""; if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && [ -z "${GIT_PS1_OMITSPARSESTATE-}" ] && [ "$(git config --bool core.sparseCheckout)" = "true" ]; then sparse="|SPARSE"; fi; local r=""; local b=""; local step=""; local total=""; if [ -d "$g/rebase-merge" ]; then __git_eread "$g/rebase-merge/head-name" b; __git_eread "$g/rebase-merge/msgnum" step; __git_eread "$g/rebase-merge/end" total; r="|REBASE"; else if [ -d "$g/rebase-apply" ]; then __git_eread "$g/rebase-apply/next" step; __git_eread "$g/rebase-apply/last" total; if [ -f "$g/rebase-apply/rebasing" ]; then __git_eread "$g/rebase-apply/head-name" b; r="|REBASE"; else if [ -f "$g/rebase-apply/applying" ]; then r="|AM"; else r="|AM/REBASE"; fi; fi; else if [ -f "$g/MERGE_HEAD" ]; then r="|MERGING"; else if __git_sequencer_status; then :; else if [ -f "$g/BISECT_LOG" ]; then r="|BISECTING"; fi; fi; fi; fi; if [ -n "$b" ]; then :; else if [ -h "$g/HEAD" ]; then b="$(git symbolic-ref HEAD 2> /dev/null)"; else local head=""; if ! __git_eread "$g/HEAD" head; then return $exit; fi; b="${head#ref: }"; if [ "$head" = "$b" ]; then detached=yes; b="$(case "${GIT_PS1_DESCRIBE_STYLE-}" in contains) git describe --contains HEAD ;; branch) git describe --contains --all HEAD ;; tag) git describe --tags HEAD ;; describe) git describe HEAD ;; * | default) git describe --tags --exact-match HEAD ;; esac 2> /dev/null)" || b="$short_sha..."; b="($b)"; fi; fi; fi; fi; if [ -n "$step" ] && [ -n "$total" ]; then r="$r $step/$total"; fi; local conflict=""; if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] && [[ -n $(git ls-files --unmerged 2> /dev/null) ]]; then conflict="|CONFLICT"; fi; local w=""; local i=""; local s=""; local u=""; local h=""; local c=""; local p=""; local upstream=""; if [ "true" = "$inside_gitdir" ]; then if [ "true" = "$bare_repo" ]; then c="BARE:"; else b="GIT_DIR!"; fi; else if [ "true" = "$inside_worktree" ]; then if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] && [ "$(git config --bool bash.showDirtyState)" != "false" ]; then git diff --no-ext-diff --quiet || w="*"; git diff --no-ext-diff --cached --quiet || i="+"; if [ -z "$short_sha" ] && [ -z "$i" ]; then i="#"; fi; fi; if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] && git rev-parse --verify --quiet refs/stash > /dev/null; then s="$"; fi; if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] && [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] && git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' > /dev/null 2> /dev/null; then u="%${ZSH_VERSION+%}"; fi; if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] && [ "$(git config --bool core.sparseCheckout)" = "true" ]; then h="?"; fi; if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then __git_ps1_show_upstream; fi; fi; fi; local z="${GIT_PS1_STATESEPARATOR-" "}"; b=${b##refs/heads/}; if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then __git_ps1_branch_name=$b; b="\${__git_ps1_branch_name}"; fi; if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then __git_ps1_colorize_gitstring; fi; local f="$h$w$i$s$u$p"; local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}${conflict}"; if [ $pcmode = yes ]; then if [ "${__git_printf_supports_v-}" != yes ]; then gitstring=$(printf -- "$printf_format" "$gitstring"); else printf -v gitstring -- "$printf_format" "$gitstring"; fi; PS1="$ps1pc_start$gitstring$ps1pc_end"; else printf -- "$printf_format" "$gitstring"; fi; return $exit } __git_ps1_colorize_gitstring () { if [[ -n ${ZSH_VERSION-} ]]; then local c_red='%F{red}'; local c_green='%F{green}'; local c_lblue='%F{blue}'; local c_clear='%f'; else local c_red='[31m'; local c_green='[32m'; local c_lblue='[1;34m'; local c_clear='[0m'; fi; local bad_color=$c_red; local ok_color=$c_green; local flags_color="$c_lblue"; local branch_color=""; if [ $detached = no ]; then branch_color="$ok_color"; else branch_color="$bad_color"; fi; if [ -n "$c" ]; then c="$branch_color$c$c_clear"; fi; b="$branch_color$b$c_clear"; if [ -n "$w" ]; then w="$bad_color$w$c_clear"; fi; if [ -n "$i" ]; then i="$ok_color$i$c_clear"; fi; if [ -n "$s" ]; then s="$flags_color$s$c_clear"; fi; if [ -n "$u" ]; then u="$bad_color$u$c_clear"; fi } __git_ps1_show_upstream () { local key value; local svn_remote svn_url_pattern count n; local upstream_type=git legacy="" verbose="" name=""; svn_remote=(); local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2> /dev/null | tr '\0\n' '\n ')"; while read -r key value; do case "$key" in bash.showupstream) GIT_PS1_SHOWUPSTREAM="$value"; if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then p=""; return; fi ;; svn-remote.*.url) svn_remote[$((${#svn_remote[@]} + 1))]="$value"; svn_url_pattern="$svn_url_pattern\\|$value"; upstream_type=svn+git ;; esac; done <<< "$output"; local option; for option in ${GIT_PS1_SHOWUPSTREAM}; do case "$option" in git | svn) upstream_type="$option" ;; verbose) verbose=1 ;; legacy) legacy=1 ;; name) name=1 ;; esac; done; case "$upstream_type" in git) upstream_type="@{upstream}" ;; svn*) local -a svn_upstream; svn_upstream=($(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2> /dev/null)); if [[ 0 -ne ${#svn_upstream[@]} ]]; then svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}; svn_upstream=${svn_upstream%@*}; local n_stop="${#svn_remote[@]}"; for ((n=1; n <= n_stop; n++)) do svn_upstream=${svn_upstream#${svn_remote[$n]}}; done; if [[ -z "$svn_upstream" ]]; then upstream_type=${GIT_SVN_ID:-git-svn}; else upstream_type=${svn_upstream#/}; fi; else if [[ "svn+git" = "$upstream_type" ]]; then upstream_type="@{upstream}"; fi; fi ;; esac; if [[ -z "$legacy" ]]; then count="$(git rev-list --count --left-right "$upstream_type"...HEAD 2> /dev/null)"; else local commits; if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2> /dev/null)"; then local commit behind=0 ahead=0; for commit in $commits; do case "$commit" in "<"*) ((behind++)) ;; *) ((ahead++)) ;; esac; done; count="$behind $ahead"; else count=""; fi; fi; if [[ -z "$verbose" ]]; then case "$count" in "") p="" ;; "0 0") p="=" ;; "0 "*) p=">" ;; *" 0") p="<" ;; *) p="<>" ;; esac; else case "$count" in "") upstream="" ;; "0 0") upstream="|u=" ;; "0 "*) upstream="|u+${count#0 }" ;; *" 0") upstream="|u-${count% 0}" ;; *) upstream="|u+${count#* }-${count% *}" ;; esac; if [[ -n "$count" && -n "$name" ]]; then __git_ps1_upstream_name=$(git rev-parse --abbrev-ref "$upstream_type" 2> /dev/null); if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then upstream="$upstream \${__git_ps1_upstream_name}"; else upstream="$upstream ${__git_ps1_upstream_name}"; unset __git_ps1_upstream_name; fi; fi; fi } __git_sequencer_status () { local todo; if test -f "$g/CHERRY_PICK_HEAD"; then r="|CHERRY-PICKING"; return 0; else if test -f "$g/REVERT_HEAD"; then r="|REVERTING"; return 0; else if __git_eread "$g/sequencer/todo" todo; then case "$todo" in p[\ \ ] | pick[\ \ ]*) r="|CHERRY-PICKING"; return 0 ;; revert[\ \ ]*) r="|REVERTING"; return 0 ;; esac; fi; fi; fi; return 1 } __load_completion () { local -a dirs=(${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions); local ifs=$IFS IFS=: dir cmd="${1##*/}" compfile; [[ -n $cmd ]] || return 1; for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}; do dirs+=($dir/bash-completion/completions); done; IFS=$ifs; if [[ $BASH_SOURCE == */* ]]; then dirs+=("${BASH_SOURCE%/*}/completions"); else dirs+=(./completions); fi; local backslash=; if [[ $cmd == \\* ]]; then cmd="${cmd:1}"; $(complete -p "$cmd" 2> /dev/null || echo false) "\\$cmd" && return 0; backslash=\\; fi; for dir in "${dirs[@]}"; do [[ -d $dir ]] || continue; for compfile in "$cmd" "$cmd.bash" "_$cmd"; do compfile="$dir/$compfile"; if [[ -f $compfile ]] && . "$compfile" &> /dev/null; then [[ -n $backslash ]] && $(complete -p "$cmd") "\\$cmd"; return 0; fi; done; done; [[ -v _xspecs[$cmd] ]] && complete -F _filedir_xspec "$cmd" "$backslash$cmd" && return 0; return 1 } __ltrim_colon_completions () { if [[ $1 == *:* && $COMP_WORDBREAKS == *:* ]]; then local colon_word=${1%"${1##*:}"}; local i=${#COMPREPLY[*]}; while ((i-- > 0)); do COMPREPLY[i]=${COMPREPLY[i]#"$colon_word"}; done; fi } __parse_options () { local option option2 i IFS=' ,/|'; option=; local -a array=($1); for i in "${array[@]}"; do case "$i" in ---*) break ;; --?*) option=$i; break ;; -?*) [[ -n $option ]] || option=$i ;; *) break ;; esac; done; [[ -n $option ]] || return 0; IFS=' '; if [[ $option =~ (\[((no|dont)-?)\]). ]]; then option2=${option/"${BASH_REMATCH[1]}"/}; option2=${option2%%[<{().[]*}; printf '%s\n' "${option2/=*/=}"; option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"}; fi; option=${option%%[<{().[]*}; printf '%s\n' "${option/=*/=}" } __reassemble_comp_words_by_ref () { local exclude i j line ref; if [[ -n $1 ]]; then exclude="[${1//[^$COMP_WORDBREAKS]/}]"; fi; printf -v "$3" %s "$COMP_CWORD"; if [[ -v exclude ]]; then line=$COMP_LINE; for ((i = 0, j = 0; i < ${#COMP_WORDS[@]}; i++, j++)) do while [[ $i -gt 0 && ${COMP_WORDS[i]} == +($exclude) ]]; do [[ $line != [[:blank:]]* ]] && ((j >= 2)) && ((j--)); ref="$2[$j]"; printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"; ((i == COMP_CWORD)) && printf -v "$3" %s "$j"; line=${line#*"${COMP_WORDS[i]}"}; [[ $line == [[:blank:]]* ]] && ((j++)); ((i < ${#COMP_WORDS[@]} - 1)) && ((i++)) || break 2; done; ref="$2[$j]"; printf -v "$ref" %s "${!ref-}${COMP_WORDS[i]}"; line=${line#*"${COMP_WORDS[i]}"}; ((i == COMP_CWORD)) && printf -v "$3" %s "$j"; done; ((i == COMP_CWORD)) && printf -v "$3" %s "$j"; else for i in "${!COMP_WORDS[@]}"; do printf -v "$2[i]" %s "${COMP_WORDS[i]}"; done; fi } _allowed_groups () { if _complete_as_root; then local IFS=' '; COMPREPLY=($(compgen -g -- "$1")); else local IFS=' '; COMPREPLY=($(compgen -W "$(id -Gn 2> /dev/null || groups 2> /dev/null)" -- "$1")); fi } _allowed_users () { if _complete_as_root; then local IFS=' '; COMPREPLY=($(compgen -u -- "${1:-$cur}")); else local IFS=' '; COMPREPLY=($(compgen -W "$(id -un 2> /dev/null || whoami 2> /dev/null)" -- "${1:-$cur}")); fi } _available_interfaces () { local PATH=$PATH:/sbin; COMPREPLY=($({ if [[ ${1:-} == -w ]]; then iwconfig; else if [[ ${1:-} == -a ]]; then ifconfig || ip link show up; else ifconfig -a || ip link show; fi; fi; } 2> /dev/null | awk '/^[^ \t]/ { if ($1 ~ /^[0-9]+:/) { print $2 } else { print $1 } }')); COMPREPLY=($(compgen -W '${COMPREPLY[@]/%[[:punct:]]/}' -- "$cur")) } _bashcomp_try_faketty () { if type unbuffer &> /dev/null; then unbuffer -p "$@"; else if script --version 2>&1 | command grep -qF util-linux; then script -qaefc "$*" /dev/null; else "$@"; fi; fi } _cd () { local cur prev words cword; _init_completion || return; local IFS=' ' i j k; compopt -o filenames; if [[ -z ${CDPATH:-} || $cur == ?(.)?(.)/* ]]; then _filedir -d; return; fi; local -r mark_dirs=$(_rl_enabled mark-directories && echo y); local -r mark_symdirs=$(_rl_enabled mark-symlinked-directories && echo y); for i in ${CDPATH//:/' '}; do k="${#COMPREPLY[@]}"; for j in $(compgen -d -- $i/$cur); do if [[ ( -n $mark_symdirs && -L $j || -n $mark_dirs && ! -L $j ) && ! -d ${j#$i/} ]]; then j+="/"; fi; COMPREPLY[k++]=${j#$i/}; done; done; _filedir -d; if ((${#COMPREPLY[@]} == 1)); then i=${COMPREPLY[0]}; if [[ $i == "$cur" && $i != "*/" ]]; then COMPREPLY[0]="${i}/"; fi; fi; return } _cd_devices () { COMPREPLY+=($(compgen -f -d -X "!*/?([amrs])cd*" -- "${cur:-/dev/}")) } _command () { local offset i; offset=1; for ((i = 1; i <= COMP_CWORD; i++)) do if [[ ${COMP_WORDS[i]} != -* ]]; then offset=$i; break; fi; done; _command_offset $offset } _command_offset () { local word_offset=$1 i j; for ((i = 0; i < word_offset; i++)) do for ((j = 0; j <= ${#COMP_LINE}; j++)) do [[ $COMP_LINE == "${COMP_WORDS[i]}"* ]] && break; COMP_LINE=${COMP_LINE:1}; ((COMP_POINT--)); done; COMP_LINE=${COMP_LINE#"${COMP_WORDS[i]}"}; ((COMP_POINT -= ${#COMP_WORDS[i]})); done; for ((i = 0; i <= COMP_CWORD - word_offset; i++)) do COMP_WORDS[i]=${COMP_WORDS[i + word_offset]}; done; for ((i; i <= COMP_CWORD; i++)) do unset 'COMP_WORDS[i]'; done; ((COMP_CWORD -= word_offset)); COMPREPLY=(); local cur; _get_comp_words_by_ref cur; if ((COMP_CWORD == 0)); then local IFS=' '; compopt -o filenames; COMPREPLY=($(compgen -d -c -- "$cur")); else local cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}; local cspec=$(complete -p $cmd 2> /dev/null); if [[ ! -n $cspec && $cmd == */* ]]; then cspec=$(complete -p ${cmd##*/} 2> /dev/null); [[ -n $cspec ]] && compcmd=${cmd##*/}; fi; if [[ ! -n $cspec ]]; then compcmd=${cmd##*/}; _completion_loader $compcmd; cspec=$(complete -p $compcmd 2> /dev/null); fi; if [[ -n $cspec ]]; then if [[ ${cspec#* -F } != "$cspec" ]]; then local func=${cspec#*-F }; func=${func%% *}; if ((${#COMP_WORDS[@]} >= 2)); then $func $cmd "${COMP_WORDS[-1]}" "${COMP_WORDS[-2]}"; else $func $cmd "${COMP_WORDS[-1]}"; fi; local opt; while [[ $cspec == *" -o "* ]]; do cspec=${cspec#*-o }; opt=${cspec%% *}; compopt -o $opt; cspec=${cspec#$opt}; done; else cspec=${cspec#complete}; cspec=${cspec%%$compcmd}; COMPREPLY=($(eval compgen "$cspec" -- '$cur')); fi; else if ((${#COMPREPLY[@]} == 0)); then _minimal; fi; fi; fi } _complete_as_root () { [[ $EUID -eq 0 || -n ${root_command:-} ]] } _completion_loader () { local cmd="${1:-_EmptycmD_}"; __load_completion "$cmd" && return 124; complete -F _minimal -- "$cmd" && return 124 } _configured_interfaces () { if [[ -f /etc/debian_version ]]; then COMPREPLY=($(compgen -W "$(command sed -ne 's|^iface \([^ ]\{1,\}\).*$|\1|p' /etc/network/interfaces /etc/network/interfaces.d/* 2> /dev/null)" -- "$cur")); else if [[ -f /etc/SuSE-release ]]; then COMPREPLY=($(compgen -W "$(printf '%s\n' /etc/sysconfig/network/ifcfg-* | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur")); else if [[ -f /etc/pld-release ]]; then COMPREPLY=($(compgen -W "$(command ls -B /etc/sysconfig/interfaces | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur")); else COMPREPLY=($(compgen -W "$(printf '%s\n' /etc/sysconfig/network-scripts/ifcfg-* | command sed -ne 's|.*ifcfg-\([^*].*\)$|\1|p')" -- "$cur")); fi; fi; fi } _count_args () { local i cword words; __reassemble_comp_words_by_ref "${1-}" words cword; args=1; for ((i = 1; i < cword; i++)) do if [[ ${words[i]} != -* && ${words[i - 1]} != ${2-} || ${words[i]} == ${3-} ]]; then ((args++)); fi; done } _dvd_devices () { COMPREPLY+=($(compgen -f -d -X "!*/?(r)dvd*" -- "${cur:-/dev/}")) } _expand () { case ${cur-} in ~*/*) __expand_tilde_by_ref cur ;; ~*) _tilde "$cur" || eval COMPREPLY[0]="$(printf ~%q "${COMPREPLY[0]#\~}")"; return ${#COMPREPLY[@]} ;; esac } _filedir () { local IFS=' '; _tilde "${cur-}" || return; local -a toks; local reset arg=${1-}; if [[ $arg == -d ]]; then reset=$(shopt -po noglob); set -o noglob; toks=($(compgen -d -- "${cur-}")); IFS=' '; $reset; IFS=' '; else local quoted; _quote_readline_by_ref "${cur-}" quoted; local xspec=${arg:+"!*.@($arg|${arg^^})"} plusdirs=(); local opts=(-f -X "$xspec"); [[ -n $xspec ]] && plusdirs=(-o plusdirs); [[ -n ${COMP_FILEDIR_FALLBACK-} || -z ${plusdirs-} ]] || opts+=("${plusdirs[@]}"); reset=$(shopt -po noglob); set -o noglob; toks+=($(compgen "${opts[@]}" -- $quoted)); IFS=' '; $reset; IFS=' '; [[ -n ${COMP_FILEDIR_FALLBACK-} && -n $arg && ${#toks[@]} -lt 1 ]] && { reset=$(shopt -po noglob); set -o noglob; toks+=($(compgen -f ${plusdirs+"${plusdirs[@]}"} -- $quoted)); IFS=' '; $reset; IFS=' ' }; fi; if ((${#toks[@]} != 0)); then compopt -o filenames 2> /dev/null; COMPREPLY+=("${toks[@]}"); fi } _filedir_xspec () { local cur prev words cword; _init_completion || return; _tilde "$cur" || return; local IFS=' ' xspec=${_xspecs[${1##*/}]} tmp; local -a toks; toks=($(compgen -d -- "$(quote_readline "$cur")" | { while read -r tmp; do printf '%s\n' $tmp; done; })); eval xspec="${xspec}"; local matchop=!; if [[ $xspec == !* ]]; then xspec=${xspec#!}; matchop=@; fi; xspec="$matchop($xspec|${xspec^^})"; toks+=($(eval compgen -f -X "'!$xspec'" -- '$(quote_readline "$cur")' | { while read -r tmp; do [[ -n $tmp ]] && printf '%s\n' $tmp; done; })); [[ -n ${COMP_FILEDIR_FALLBACK:-} && ${#toks[@]} -lt 1 ]] && { local reset=$(shopt -po noglob); set -o noglob; toks+=($(compgen -f -- "$(quote_readline "$cur")")); IFS=' '; $reset; IFS=' ' }; if ((${#toks[@]} != 0)); then compopt -o filenames; COMPREPLY=("${toks[@]}"); fi } _fstypes () { local fss; if [[ -e /proc/filesystems ]]; then fss="$(cut -d' ' -f2 /proc/filesystems) $(awk '! /\*/ { print $NF }' /etc/filesystems 2> /dev/null)"; else fss="$(awk '/^[ \t]*[^#]/ { print $3 }' /etc/fstab 2> /dev/null) $(awk '/^[ \t]*[^#]/ { print $3 }' /etc/mnttab 2> /dev/null) $(awk '/^[ \t]*[^#]/ { print $4 }' /etc/vfstab 2> /dev/null) $(awk '{ print $1 }' /etc/dfs/fstypes 2> /dev/null) $([[ -d /etc/fs ]] && command ls /etc/fs)"; fi; [[ -n $fss ]] && COMPREPLY+=($(compgen -W "$fss" -- "$cur")) } _get_comp_words_by_ref () { local exclude flag i OPTIND=1; local cur cword words=(); local upargs=() upvars=() vcur vcword vprev vwords; while getopts "c:i:n:p:w:" flag "$@"; do case $flag in c) vcur=$OPTARG ;; i) vcword=$OPTARG ;; n) exclude=$OPTARG ;; p) vprev=$OPTARG ;; w) vwords=$OPTARG ;; *) echo "bash_completion: $FUNCNAME: usage error" 1>&2; return 1 ;; esac; done; while [[ $# -ge $OPTIND ]]; do case ${!OPTIND} in cur) vcur=cur ;; prev) vprev=prev ;; cword) vcword=cword ;; words) vwords=words ;; *) echo "bash_completion: $FUNCNAME: \`${!OPTIND}':" "unknown argument" 1>&2; return 1 ;; esac; ((OPTIND += 1)); done; __get_cword_at_cursor_by_ref "${exclude-}" words cword cur; [[ -v vcur ]] && { upvars+=("$vcur"); upargs+=(-v $vcur "$cur") }; [[ -v vcword ]] && { upvars+=("$vcword"); upargs+=(-v $vcword "$cword") }; [[ -v vprev && $cword -ge 1 ]] && { upvars+=("$vprev"); upargs+=(-v $vprev "${words[cword - 1]}") }; [[ -v vwords ]] && { upvars+=("$vwords"); upargs+=(-a${#words[@]} $vwords ${words+"${words[@]}"}) }; ((${#upvars[@]})) && local "${upvars[@]}" && _upvars "${upargs[@]}" } _get_cword () { local LC_CTYPE=C; local cword words; __reassemble_comp_words_by_ref "${1-}" words cword; if [[ -n ${2-} && -n ${2//[^0-9]/} ]]; then printf "%s" "${words[cword - $2]}"; else if ((${#words[cword]} == 0 && COMP_POINT == ${#COMP_LINE})); then :; else local i; local cur="$COMP_LINE"; local index="$COMP_POINT"; for ((i = 0; i <= cword; ++i)) do while [[ ${#cur} -ge ${#words[i]} && ${cur:0:${#words[i]}} != "${words[i]}" ]]; do cur="${cur:1}"; ((index > 0)) && ((index--)); done; if ((i < cword)); then local old_size="${#cur}"; cur="${cur#${words[i]}}"; local new_size="${#cur}"; ((index -= old_size - new_size)); fi; done; if [[ ${words[cword]:0:${#cur}} != "$cur" ]]; then printf "%s" "${words[cword]}"; else printf "%s" "${cur:0:index}"; fi; fi; fi } _get_first_arg () { local i; arg=; for ((i = 1; i < COMP_CWORD; i++)) do if [[ ${COMP_WORDS[i]} != -* ]]; then arg=${COMP_WORDS[i]}; break; fi; done } _get_pword () { if ((COMP_CWORD >= 1)); then _get_cword "${@:-}" 1; fi } _gids () { if type getent &> /dev/null; then COMPREPLY=($(compgen -W '$(getent group | cut -d: -f3)' -- "$cur")); else if type perl &> /dev/null; then COMPREPLY=($(compgen -W '$(perl -e '"'"'while (($gid) = (getgrent)[2]) { print $gid . "\n" }'"'"')' -- "$cur")); else COMPREPLY=($(compgen -W '$(cut -d: -f3 /etc/group)' -- "$cur")); fi; fi } _have () { PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin type $1 &> /dev/null } _included_ssh_config_files () { (($# < 1)) && echo "bash_completion: $FUNCNAME: missing mandatory argument CONFIG" 1>&2; local configfile i f; configfile=$1; local reset=$(shopt -po noglob); set -o noglob; local included=($(command sed -ne 's/^[[:blank:]]*[Ii][Nn][Cc][Ll][Uu][Dd][Ee][[:blank:]]\(.*\)$/\1/p' "${configfile}")); $reset; [[ -n ${included-} ]] || return; for i in "${included[@]}"; do if ! [[ $i =~ ^\~.*|^\/.* ]]; then if [[ $configfile =~ ^\/etc\/ssh.* ]]; then i="/etc/ssh/$i"; else i="$HOME/.ssh/$i"; fi; fi; __expand_tilde_by_ref i; set +o noglob; for f in $i; do if [[ -r $f ]]; then config+=("$f"); _included_ssh_config_files $f; fi; done; $reset; done } _init_completion () { local exclude="" flag outx errx inx OPTIND=1; while getopts "n:e:o:i:s" flag "$@"; do case $flag in n) exclude+=$OPTARG ;; e) errx=$OPTARG ;; o) outx=$OPTARG ;; i) inx=$OPTARG ;; s) split=false; exclude+== ;; *) echo "bash_completion: $FUNCNAME: usage error" 1>&2; return 1 ;; esac; done; COMPREPLY=(); local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)"; _get_comp_words_by_ref -n "$exclude<>&" cur prev words cword; _variables && return 1; if [[ $cur == $redir* || ${prev-} == $redir ]]; then local xspec; case $cur in 2'>'*) xspec=${errx-} ;; *'>'*) xspec=${outx-} ;; *'<'*) xspec=${inx-} ;; *) case $prev in 2'>'*) xspec=${errx-} ;; *'>'*) xspec=${outx-} ;; *'<'*) xspec=${inx-} ;; esac ;; esac; cur="${cur##$redir}"; _filedir $xspec; return 1; fi; local i skip; for ((i = 1; i < ${#words[@]}; 1)) do if [[ ${words[i]} == $redir* ]]; then [[ ${words[i]} == $redir ]] && skip=2 || skip=1; words=("${words[@]:0:i}" "${words[@]:i+skip}"); ((i <= cword)) && ((cword -= skip)); else ((i++)); fi; done; ((cword <= 0)) && return 1; prev=${words[cword - 1]}; [[ -n ${split-} ]] && _split_longopt && split=true; return 0 } _installed_modules () { COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" lsmod | awk '{if (NR != 1) print $1}')" -- "$1")) } _ip_addresses () { local n; case ${1-} in -a) n='6\?' ;; -6) n='6' ;; *) n= ;; esac; local PATH=$PATH:/sbin; local addrs=$({ LC_ALL=C ifconfig -a || ip addr show; } 2> /dev/null | command sed -e 's/[[:space:]]addr:/ /' -ne "s|.*inet${n}[[:space:]]\{1,\}\([^[:space:]/]*\).*|\1|p"); COMPREPLY+=($(compgen -W "$addrs" -- "${cur-}")) } _kernel_versions () { COMPREPLY=($(compgen -W '$(command ls /lib/modules)' -- "$cur")) } _known_hosts () { local cur prev words cword; _init_completion -n : || return; local options; [[ ${1-} == -a || ${2-} == -a ]] && options=-a; [[ ${1-} == -c || ${2-} == -c ]] && options+=" -c"; _known_hosts_real ${options-} -- "$cur" } _known_hosts_real () { local configfile flag prefix="" ifs=$IFS; local cur suffix="" aliases i host ipv4 ipv6; local -a kh tmpkh=() khd=() config=(); local OPTIND=1; while getopts "ac46F:p:" flag "$@"; do case $flag in a) aliases='yes' ;; c) suffix=':' ;; F) configfile=$OPTARG ;; p) prefix=$OPTARG ;; 4) ipv4=1 ;; 6) ipv6=1 ;; *) echo "bash_completion: $FUNCNAME: usage error" 1>&2; return 1 ;; esac; done; if (($# < OPTIND)); then echo "bash_completion: $FUNCNAME: missing mandatory argument CWORD" 1>&2; return 1; fi; cur=${!OPTIND}; ((OPTIND += 1)); if (($# >= OPTIND)); then echo "bash_completion: $FUNCNAME($*): unprocessed arguments:" "$(while (($# >= OPTIND)); do printf '%s ' ${!OPTIND} shift; done)" 1>&2; return 1; fi; [[ $cur == *@* ]] && prefix=$prefix${cur%@*}@ && cur=${cur#*@}; kh=(); if [[ -v configfile ]]; then [[ -r $configfile ]] && config+=("$configfile"); else for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do [[ -r $i ]] && config+=("$i"); done; fi; local reset=$(shopt -po noglob); set -o noglob; if ((${#config[@]} > 0)); then for i in "${config[@]}"; do _included_ssh_config_files "$i"; done; fi; if ((${#config[@]} > 0)); then local IFS=' '; tmpkh=($(awk 'sub("^[ \t]*([Gg][Ll][Oo][Bb][Aa][Ll]|[Uu][Ss][Ee][Rr])[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee][ \t]+", "") { print $0 }' "${config[@]}" | sort -u)); IFS=$ifs; fi; if ((${#tmpkh[@]} != 0)); then local j; for i in "${tmpkh[@]}"; do while [[ $i =~ ^([^\"]*)\"([^\"]*)\"(.*)$ ]]; do i=${BASH_REMATCH[1]}${BASH_REMATCH[3]}; j=${BASH_REMATCH[2]}; __expand_tilde_by_ref j; [[ -r $j ]] && kh+=("$j"); done; for j in $i; do __expand_tilde_by_ref j; [[ -r $j ]] && kh+=("$j"); done; done; fi; if [[ ! -v configfile ]]; then for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 /etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts ~/.ssh/known_hosts2; do [[ -r $i ]] && kh+=("$i"); done; for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do [[ -d $i ]] && khd+=("$i"/*pub); done; fi; if ((${#kh[@]} + ${#khd[@]} > 0)); then if ((${#kh[@]} > 0)); then for i in "${kh[@]}"; do while read -ra tmpkh; do ((${#tmpkh[@]} == 0)) && continue; set -- "${tmpkh[@]}"; [[ $1 == [\|\#]* ]] && continue; [[ $1 == @* ]] && shift; local IFS=,; for host in $1; do [[ $host == *[*?]* ]] && continue; host="${host#[}"; host="${host%]?(:+([0-9]))}"; COMPREPLY+=($host); done; IFS=$ifs; done < "$i"; done; COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")); fi; if ((${#khd[@]} > 0)); then for i in "${khd[@]}"; do if [[ $i == *key_22_$cur*.pub && -r $i ]]; then host=${i/#*key_22_/}; host=${host/%.pub/}; COMPREPLY+=($host); fi; done; fi; for i in ${!COMPREPLY[*]}; do COMPREPLY[i]=$prefix${COMPREPLY[i]}$suffix; done; fi; if [[ ${#config[@]} -gt 0 && -v aliases ]]; then local -a hosts=($(command sed -ne 's/^[[:blank:]]*[Hh][Oo][Ss][Tt][[:blank:]]\(.*\)$/\1/p' "${config[@]}")); if ((${#hosts[@]} != 0)); then COMPREPLY+=($(compgen -P "$prefix" -S "$suffix" -W '${hosts[@]%%[*?%]*}' -X '\!*' -- "$cur")); fi; fi; if [[ -n ${COMP_KNOWN_HOSTS_WITH_AVAHI-} ]] && type avahi-browse &> /dev/null; then COMPREPLY+=($(compgen -P "$prefix" -S "$suffix" -W "$(avahi-browse -cpr _workstation._tcp 2> /dev/null | awk -F';' '/^=/ { print $7 }' | sort -u)" -- "$cur")); fi; if type ruptime &> /dev/null; then COMPREPLY+=($(compgen -W "$(ruptime 2> /dev/null | awk '!/^ruptime:/ { print $1 }')" -- "$cur")); fi; if [[ -n ${COMP_KNOWN_HOSTS_WITH_HOSTFILE-1} ]]; then COMPREPLY+=($(compgen -A hostname -P "$prefix" -S "$suffix" -- "$cur")); fi; $reset; if [[ -v ipv4 ]]; then COMPREPLY=("${COMPREPLY[@]/*:*$suffix/}"); fi; if [[ -v ipv6 ]]; then COMPREPLY=("${COMPREPLY[@]/+([0-9]).+([0-9]).+([0-9]).+([0-9])$suffix/}"); fi; if [[ -v ipv4 || -v ipv6 ]]; then for i in "${!COMPREPLY[@]}"; do [[ -n ${COMPREPLY[i]} ]] || unset -v "COMPREPLY[i]"; done; fi; __ltrim_colon_completions "$prefix$cur" } _longopt () { local cur prev words cword split; _init_completion -s || return; case "${prev,,}" in --help | --usage | --version) return ;; --!(no-*)dir*) _filedir -d; return ;; --!(no-*)@(file|path)*) _filedir; return ;; --+([-a-z0-9_])) local argtype=$(LC_ALL=C $1 --help 2>&1 | command sed -ne "s|.*$prev\[\{0,1\}=[<[]\{0,1\}\([-A-Za-z0-9_]\{1,\}\).*|\1|p"); case ${argtype,,} in *dir*) _filedir -d; return ;; *file* | *path*) _filedir; return ;; esac ;; esac; $split && return; if [[ $cur == -* ]]; then COMPREPLY=($(compgen -W "$(LC_ALL=C $1 --help 2>&1 | while read -r line; do [[ $line =~ --[A-Za-z0-9]+([-_][A-Za-z0-9]+)*=? ]] && printf '%s\n' ${BASH_REMATCH[0]}; done)" -- "$cur")); [[ ${COMPREPLY-} == *= ]] && compopt -o nospace; else if [[ $1 == *@(rmdir|chroot) ]]; then _filedir -d; else [[ $1 == *mkdir ]] && compopt -o nospace; _filedir; fi; fi } _mac_addresses () { local re='\([A-Fa-f0-9]\{2\}:\)\{5\}[A-Fa-f0-9]\{2\}'; local PATH="$PATH:/sbin:/usr/sbin"; COMPREPLY+=($({ LC_ALL=C ifconfig -a || ip link show; } 2> /dev/null | command sed -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]HWaddr[[:space:]]\{1,\}\($re\)[[:space:]]*$/\1/p" -ne "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]].*|\2|p" -ne "s|.*[[:space:]]\(link/\)\{0,1\}ether[[:space:]]\{1,\}\($re\)[[:space:]]*$|\2|p")); COMPREPLY+=($({ arp -an || ip neigh show; } 2> /dev/null | command sed -ne "s/.*[[:space:]]\($re\)[[:space:]].*/\1/p" -ne "s/.*[[:space:]]\($re\)[[:space:]]*$/\1/p")); COMPREPLY+=($(command sed -ne "s/^[[:space:]]*\($re\)[[:space:]].*/\1/p" /etc/ethers 2> /dev/null)); COMPREPLY=($(compgen -W '${COMPREPLY[@]}' -- "$cur")); __ltrim_colon_completions "$cur" } _minimal () { local cur prev words cword split; _init_completion -s || return; $split && return; _filedir } _modules () { local modpath; modpath=/lib/modules/$1; COMPREPLY=($(compgen -W "$(command ls -RL $modpath 2> /dev/null | command sed -ne 's/^\(.*\)\.k\{0,1\}o\(\.[gx]z\)\{0,1\}$/\1/p')" -- "$cur")) } _ncpus () { local var=NPROCESSORS_ONLN; [[ $OSTYPE == *linux* ]] && var=_$var; local n=$(getconf $var 2> /dev/null); printf %s ${n:-1} } _parse_help () { eval local cmd="$(quote "$1")"; local line; { case $cmd in -) cat ;; *) LC_ALL=C "$(dequote "$cmd")" ${2:---help} 2>&1 ;; esac } | while read -r line; do [[ $line == *([[:blank:]])-* ]] || continue; while [[ $line =~ ((^|[^-])-[A-Za-z0-9?][[:space:]]+)\[?[A-Z0-9]+([,_-]+[A-Z0-9]+)?(\.\.+)?\]? ]]; do line=${line/"${BASH_REMATCH[0]}"/"${BASH_REMATCH[1]}"}; done; __parse_options "${line// or /, }"; done } _parse_usage () { eval local cmd="$(quote "$1")"; local line match option i char; { case $cmd in -) cat ;; *) LC_ALL=C "$(dequote "$cmd")" ${2:---usage} 2>&1 ;; esac } | while read -r line; do while [[ $line =~ \[[[:space:]]*(-[^]]+)[[:space:]]*\] ]]; do match=${BASH_REMATCH[0]}; option=${BASH_REMATCH[1]}; case $option in -?(\[)+([a-zA-Z0-9?])) for ((i = 1; i < ${#option}; i++)) do char=${option:i:1}; [[ $char != '[' ]] && printf '%s\n' -$char; done ;; *) __parse_options "$option" ;; esac; line=${line#*"$match"}; done; done } _pci_ids () { COMPREPLY+=($(compgen -W "$(PATH="$PATH:/sbin" lspci -n | awk '{print $3}')" -- "$cur")) } _pgids () { COMPREPLY=($(compgen -W '$(command ps axo pgid=)' -- "$cur")) } _pids () { COMPREPLY=($(compgen -W '$(command ps axo pid=)' -- "$cur")) } _pnames () { local -a procs; if [[ ${1-} == -s ]]; then procs=($(command ps axo comm | command sed -e 1d)); else local line i=-1 ifs=$IFS; IFS=' '; local -a psout=($(command ps axo command=)); IFS=$ifs; for line in "${psout[@]}"; do if ((i == -1)); then if [[ $line =~ ^(.*[[:space:]])COMMAND([[:space:]]|$) ]]; then i=${#BASH_REMATCH[1]}; else break; fi; else line=${line:i}; line=${line%% *}; procs+=($line); fi; done; if ((i == -1)); then for line in "${psout[@]}"; do if [[ $line =~ ^[[(](.+)[])]$ ]]; then procs+=(${BASH_REMATCH[1]}); else line=${line%% *}; line=${line##@(*/|-)}; procs+=($line); fi; done; fi; fi; COMPREPLY=($(compgen -X "<defunct>" -W '${procs[@]}' -- "$cur")) } _quote_readline_by_ref () { if [[ $1 == \'* ]]; then printf -v $2 %s "${1:1}"; else printf -v $2 %q "$1"; fi; [[ ${!2} == \$* ]] && eval $2=${!2} } _realcommand () { type -P "$1" > /dev/null && { if type -p realpath > /dev/null; then realpath "$(type -P "$1")"; else if type -p greadlink > /dev/null; then greadlink -f "$(type -P "$1")"; else if type -p readlink > /dev/null; then readlink -f "$(type -P "$1")"; else type -P "$1"; fi; fi; fi } } _rl_enabled () { [[ "$(bind -v)" == *$1+([[:space:]])on* ]] } _root_command () { local PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin; local root_command=$1; _command } _service () { local cur prev words cword; _init_completion || return; ((cword > 2)) && return; if [[ $cword -eq 1 && $prev == ?(*/)service ]]; then _services; [[ -e /etc/mandrake-release ]] && _xinetd_services; else local sysvdirs; _sysvdirs; COMPREPLY=($(compgen -W '`command sed -e "y/|/ /" \ -ne "s/^.*\(U\|msg_u\)sage.*{\(.*\)}.*$/\2/p" \ ${sysvdirs[0]}/${prev##*/} 2>/dev/null` start stop' -- "$cur")); fi } _services () { local sysvdirs; _sysvdirs; local IFS=' ' reset=$(shopt -p nullglob); shopt -s nullglob; COMPREPLY=($(printf '%s\n' ${sysvdirs[0]}/!($_backup_glob|functions|README))); $reset; COMPREPLY+=($({ systemctl list-units --full --all || systemctl list-unit-files; } 2> /dev/null | awk '$1 ~ /\.service$/ { sub("\\.service$", "", $1); print $1 }')); if [[ -x /sbin/upstart-udev-bridge ]]; then COMPREPLY+=($(initctl list 2> /dev/null | cut -d' ' -f1)); fi; COMPREPLY=($(compgen -W '${COMPREPLY[@]#${sysvdirs[0]}/}' -- "$cur")) } _shells () { local shell rest; while read -r shell rest; do [[ $shell == /* && $shell == "$cur"* ]] && COMPREPLY+=($shell); done 2> /dev/null < /etc/shells } _signals () { local -a sigs=($(compgen -P "${1-}" -A signal "SIG${cur#${1-}}")); COMPREPLY+=("${sigs[@]/#${1-}SIG/${1-}}") } _split_longopt () { if [[ $cur == --?*=* ]]; then prev="${cur%%?(\\)=*}"; cur="${cur#*=}"; return 0; fi; return 1 } _sysvdirs () { sysvdirs=(); [[ -d /etc/rc.d/init.d ]] && sysvdirs+=(/etc/rc.d/init.d); [[ -d /etc/init.d ]] && sysvdirs+=(/etc/init.d); [[ -f /etc/slackware-version ]] && sysvdirs=(/etc/rc.d); return 0 } _terms () { COMPREPLY+=($(compgen -W "$({ command sed -ne 's/^\([^[:space:]#|]\{2,\}\)|.*/\1/p' /etc/termcap { toe -a || toe; } | awk '{ print $1 }' find /{etc,lib,usr/lib,usr/share}/terminfo/? -type f -maxdepth 1 | awk -F/ '{ print $NF }'; } 2> /dev/null)" -- "$cur")) } _tilde () { local result=0; if [[ ${1-} == \~* && $1 != */* ]]; then COMPREPLY=($(compgen -P '~' -u -- "${1#\~}")); result=${#COMPREPLY[@]}; ((result > 0)) && compopt -o filenames 2> /dev/null; fi; return $result } _uids () { if type getent &> /dev/null; then COMPREPLY=($(compgen -W '$(getent passwd | cut -d: -f3)' -- "$cur")); else if type perl &> /dev/null; then COMPREPLY=($(compgen -W '$(perl -e '"'"'while (($uid) = (getpwent)[2]) { print $uid . "\n" }'"'"')' -- "$cur")); else COMPREPLY=($(compgen -W '$(cut -d: -f3 /etc/passwd)' -- "$cur")); fi; fi } _upvar () { echo "bash_completion: $FUNCNAME: deprecated function," "use _upvars instead" 1>&2; if unset -v "$1"; then if (($# == 2)); then eval $1=\"\$2\"; else eval $1=\(\"\$"{@:2}"\"\); fi; fi } _upvars () { if ! (($#)); then echo "bash_completion: $FUNCNAME: usage: $FUNCNAME" "[-v varname value] | [-aN varname [value ...]] ..." 1>&2; return 2; fi; while (($#)); do case $1 in -a*) [[ -n ${1#-a} ]] || { echo "bash_completion: $FUNCNAME:" "\`$1': missing number specifier" 1>&2; return 1 }; printf %d "${1#-a}" &> /dev/null || { echo bash_completion: "$FUNCNAME: \`$1': invalid number specifier" 1>&2; return 1 }; [[ -n "$2" ]] && unset -v "$2" && eval $2=\(\"\$"{@:3:${1#-a}}"\"\) && shift $((${1#-a} + 2)) || { echo bash_completion: "$FUNCNAME: \`$1${2+ }$2': missing argument(s)" 1>&2; return 1 } ;; -v) [[ -n "$2" ]] && unset -v "$2" && eval $2=\"\$3\" && shift 3 || { echo "bash_completion: $FUNCNAME: $1:" "missing argument(s)" 1>&2; return 1 } ;; *) echo "bash_completion: $FUNCNAME: $1: invalid option" 1>&2; return 1 ;; esac; done } _usb_ids () { COMPREPLY+=($(compgen -W "$(PATH="$PATH:/sbin" lsusb | awk '{print $6}')" -- "$cur")) } _user_at_host () { local cur prev words cword; _init_completion -n : || return; if [[ $cur == *@* ]]; then _known_hosts_real "$cur"; else COMPREPLY=($(compgen -u -S @ -- "$cur")); compopt -o nospace; fi } _usergroup () { if [[ $cur == *\\\\* || $cur == *:*:* ]]; then return; else if [[ $cur == *\\:* ]]; then local prefix; prefix=${cur%%*([^:])}; prefix=${prefix//\\/}; local mycur="${cur#*[:]}"; if [[ ${1-} == -u ]]; then _allowed_groups "$mycur"; else local IFS=' '; COMPREPLY=($(compgen -g -- "$mycur")); fi; COMPREPLY=($(compgen -P "$prefix" -W "${COMPREPLY[@]}")); else if [[ $cur == *:* ]]; then local mycur="${cur#*:}"; if [[ ${1-} == -u ]]; then _allowed_groups "$mycur"; else local IFS=' '; COMPREPLY=($(compgen -g -- "$mycur")); fi; else if [[ ${1-} == -u ]]; then _allowed_users "$cur"; else local IFS=' '; COMPREPLY=($(compgen -u -- "$cur")); fi; fi; fi; fi } _userland () { local userland=$(uname -s); [[ $userland == @(Linux|GNU/*) ]] && userland=GNU; [[ $userland == "$1" ]] } _variable_assignments () { local cur=${1-}; if [[ $cur =~ ^([A-Za-z_][A-Za-z0-9_]*)=(.*)$ ]]; then prev=${BASH_REMATCH[1]}; cur=${BASH_REMATCH[2]}; else return 1; fi; case $prev in TZ) cur=/usr/share/zoneinfo/$cur; _filedir; for i in "${!COMPREPLY[@]}"; do if [[ ${COMPREPLY[i]} == *.tab ]]; then unset 'COMPREPLY[i]'; continue; else if [[ -d ${COMPREPLY[i]} ]]; then COMPREPLY[i]+=/; compopt -o nospace; fi; fi; COMPREPLY[i]=${COMPREPLY[i]#/usr/share/zoneinfo/}; done ;; TERM) _terms ;; LANG | LC_*) COMPREPLY=($(compgen -W '$(locale -a 2>/dev/null)' -- "$cur")) ;; *) _variables && return 0; _filedir ;; esac; return 0 } _variables () { if [[ $cur =~ ^(\$(\{[!#]?)?)([A-Za-z0-9_]*)$ ]]; then if [[ $cur == '${'* ]]; then local arrs vars; vars=($(compgen -A variable -P ${BASH_REMATCH[1]} -S '}' -- ${BASH_REMATCH[3]})); arrs=($(compgen -A arrayvar -P ${BASH_REMATCH[1]} -S '[' -- ${BASH_REMATCH[3]})); if ((${#vars[@]} == 1 && ${#arrs[@]} != 0)); then compopt -o nospace; COMPREPLY+=(${arrs[*]}); else COMPREPLY+=(${vars[*]}); fi; else COMPREPLY+=($(compgen -A variable -P '$' -- "${BASH_REMATCH[3]}")); fi; return 0; else if [[ $cur =~ ^(\$\{[#!]?)([A-Za-z0-9_]*)\[([^]]*)$ ]]; then local IFS=' '; COMPREPLY+=($(compgen -W '$(printf %s\\n "${!'${BASH_REMATCH[2]}'[@]}")' -P "${BASH_REMATCH[1]}${BASH_REMATCH[2]}[" -S ']}' -- "${BASH_REMATCH[3]}")); if [[ ${BASH_REMATCH[3]} == [@*] ]]; then COMPREPLY+=("${BASH_REMATCH[1]}${BASH_REMATCH[2]}[${BASH_REMATCH[3]}]}"); fi; __ltrim_colon_completions "$cur"; return 0; else if [[ $cur =~ ^\$\{[#!]?[A-Za-z0-9_]*\[.*\]$ ]]; then COMPREPLY+=("$cur}"); __ltrim_colon_completions "$cur"; return 0; fi; fi; fi; return 1 } _xfunc () { set -- "$@"; local srcfile=$1; shift; declare -F $1 &> /dev/null || __load_completion "$srcfile"; "$@" } _xinetd_services () { local xinetddir=${BASHCOMP_XINETDDIR:-/etc/xinetd.d}; if [[ -d $xinetddir ]]; then local IFS=' ' reset=$(shopt -p nullglob); shopt -s nullglob; local -a svcs=($(printf '%s\n' $xinetddir/!($_backup_glob))); $reset; ((!${#svcs[@]})) || COMPREPLY+=($(compgen -W '${svcs[@]#$xinetddir/}' -- "${cur-}")); fi } command_not_found_handle () { if [ -x /usr/lib/command-not-found ]; then /usr/lib/command-not-found -- "$1"; return $?; else if [ -x /usr/share/command-not-found/command-not-found ]; then /usr/share/command-not-found/command-not-found -- "$1"; return $?; else printf "%s: command not found\n" "$1" 1>&2; return 127; fi; fi } dequote () { eval printf %s "$1" 2> /dev/null } quote () { local quoted=${1//\'/\'\\\'\'}; printf "'%s'" "$quoted" } quote_readline () { local ret; _quote_readline_by_ref "$1" ret; printf %s "$ret" } tests.
This commit is contained in:
parent
1dc5d06000
commit
b4a59f5467
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@
|
||||
/Python/Abstracts/Applications.py
|
||||
.sass-cache
|
||||
__pycache__
|
||||
/CSharp/obj
|
||||
/CSharp/bin
|
||||
@ -1,40 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net.Mail;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ErrorsManager{
|
||||
|
||||
// public abstract record Error{
|
||||
|
||||
// private Error(){}
|
||||
|
||||
// public sealed record String(string value):Error;
|
||||
// public sealed record Array(byte[] value):Error;
|
||||
// public sealed record Integer(int value):Error;
|
||||
|
||||
// }
|
||||
|
||||
class ErrorsManager{
|
||||
public class ErrorsManager{
|
||||
|
||||
public static readonly char[] ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".ToCharArray();
|
||||
|
||||
public static readonly string[] ERRORS_MESSAGES = new string[]{
|
||||
"invalid_alphabet",
|
||||
"invalid_base",
|
||||
"invalid_alphabet_type",
|
||||
"too_short_alphabet",
|
||||
"repeated_characters_in_alphabet",
|
||||
"too_long_alphabet",
|
||||
"base_lower_than_2",
|
||||
"base_greater_than_128",
|
||||
"base_greater_than_alphabet"
|
||||
};
|
||||
|
||||
public static readonly Regex RE_KEY = new Regex(@"^[a-z_][a-z0-9_]*$", RegexOptions.IgnoreCase | RegexOptions.Compiled);
|
||||
|
||||
private Error error = 0;
|
||||
private char[] alphabet;
|
||||
private int error = 0;
|
||||
private char[] alphabet = new char[0];
|
||||
private Dictionary<char, byte> dictionary = new Dictionary<char, byte>();
|
||||
private byte _base;
|
||||
private byte power;
|
||||
|
||||
public ErrorsManager(object? inputs = null){
|
||||
public ErrorsManager(object inputs = null){
|
||||
|
||||
set_alphabet(get<object?>("alphabet", inputs, ALPHABET));
|
||||
set_alphabet(
|
||||
get<object>("alphabet", inputs, ALPHABET),
|
||||
get<int>("base", inputs, 64)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public int set_alphabet(object? alphabet = null){
|
||||
public int set_alphabet(object alphabet = null, int _base = 64){
|
||||
|
||||
int original_length;
|
||||
|
||||
@ -64,9 +69,18 @@ namespace ErrorsManager{
|
||||
if(this.alphabet.Length > 128)
|
||||
error |= 1 << 5;
|
||||
|
||||
error |= (
|
||||
_base < 2 ? 1 << 0 :
|
||||
_base > 128 ? 1 << 1 :
|
||||
_base >= this.alphabet.Length ? 1 << 2 :
|
||||
0) << 6;
|
||||
|
||||
if(error >> 6 == 0)
|
||||
this.alphabet = this.alphabet.Take(_base).ToArray<char>();
|
||||
|
||||
this.alphabet = this.alphabet.Take(
|
||||
_base = (byte)Math.Pow(2,
|
||||
power = (byte)Math.Log2(this.alphabet.Length)
|
||||
this._base = (byte)Math.Pow(2,
|
||||
power = (byte)Math.Log2(this.alphabet.Take(128).Count<char>())
|
||||
)
|
||||
).ToArray<char>();
|
||||
|
||||
@ -81,73 +95,96 @@ namespace ErrorsManager{
|
||||
return new string(alphabet);
|
||||
}
|
||||
|
||||
public byte[] to_array(object code){
|
||||
if(code is string _string)
|
||||
return _string.Select<char, byte>(character => dictionary[character]).ToArray<byte>();
|
||||
if(code is byte[] array)
|
||||
return array;
|
||||
if(code is int integer){
|
||||
public byte[] to_array(string code){
|
||||
return code.Select<char, byte>(character => dictionary[character]).ToArray<byte>();
|
||||
}
|
||||
|
||||
public byte[] to_array(byte[] code){
|
||||
return code;
|
||||
}
|
||||
|
||||
public byte[] to_array(int code){
|
||||
|
||||
List<byte> hexas = new List<byte>();
|
||||
|
||||
while(integer != 0){
|
||||
hexas.Add((byte)(integer % _base));
|
||||
integer /= _base;
|
||||
while(code != 0){
|
||||
hexas.Add((byte)(code % _base));
|
||||
code /= _base;
|
||||
}
|
||||
|
||||
return hexas.ToArray<byte>();
|
||||
}
|
||||
return new byte[]{};
|
||||
|
||||
public string to_string(byte[] code){
|
||||
return new string(code.Select<byte, char>(value => alphabet[value]).ToArray<char>());
|
||||
}
|
||||
|
||||
public string to_string(object code){
|
||||
if(code is string _string)
|
||||
return _string;
|
||||
if(code is byte[] array)
|
||||
return new string(array.Select<byte, char>(value => alphabet[value]).ToArray<char>());
|
||||
if(code is int integer){
|
||||
public string to_string(int code){
|
||||
string hexas = "";
|
||||
|
||||
string hexas = new string();
|
||||
|
||||
while(integer != 0){
|
||||
hexas += alphabet[(byte)(integer % _base)];
|
||||
integer /= _base;
|
||||
while(code != 0){
|
||||
hexas += alphabet[(byte)(code % _base)];
|
||||
code /= _base;
|
||||
}
|
||||
|
||||
return hexas;
|
||||
}
|
||||
return "";
|
||||
|
||||
public string to_string(string code){
|
||||
return code;
|
||||
}
|
||||
|
||||
public int to_integer(object code){
|
||||
if(code is string _string){
|
||||
public int to_integer(string code){
|
||||
|
||||
int integer = 0;
|
||||
int _string = 0;
|
||||
|
||||
for(byte i = 0; i < _string.Length; i ++)
|
||||
integer = integer * _base + dictionary[_string[i]];
|
||||
for(int i = code.Length - 1; i >= 0; i --)
|
||||
_string = _string * _base + dictionary[code[i]];
|
||||
|
||||
return integer;
|
||||
}
|
||||
if(code is byte[] array){
|
||||
|
||||
int integer = 0;
|
||||
|
||||
for(byte i = 0; i < array.Length; i ++)
|
||||
integer = integer * _base + array[i];
|
||||
|
||||
return integer;
|
||||
}
|
||||
if(code is int integer)
|
||||
return integer;
|
||||
return 0;
|
||||
return _string;
|
||||
}
|
||||
|
||||
public (int, string)[] process(Error code, IEnumerable<string> messages){
|
||||
public int to_integer(byte[] code){
|
||||
|
||||
int array = 0;
|
||||
|
||||
for(int i = code.Length - 1; i >= 0; i --)
|
||||
array = array * _base + code[i];
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
public int to_integer(int code){
|
||||
return code;
|
||||
}
|
||||
|
||||
public string to_string_binary(string code){
|
||||
return string.Join("", code.Reverse<char>().Select<char, string>(character => Convert.ToString(dictionary[character], 2).PadLeft(power, '0')));
|
||||
}
|
||||
|
||||
public string to_string_binary(byte[] code){
|
||||
return string.Join("", code.Reverse<byte>().Select<byte, string>(hexa => Convert.ToString(hexa, 2).PadLeft(power, '0')));
|
||||
}
|
||||
|
||||
public string to_string_binary(int code){
|
||||
|
||||
string binary = Convert.ToString(code, 2);
|
||||
int remainer = binary.Length % power;
|
||||
|
||||
return (
|
||||
remainer == 0 ? binary :
|
||||
binary.PadLeft(binary.Length + power - remainer, '0'));
|
||||
}
|
||||
|
||||
public (int, string)[] process(string code, IEnumerable<string> messages){
|
||||
return process(to_array(code), messages);
|
||||
}
|
||||
|
||||
public (int, string)[] process(byte[] code, IEnumerable<string> messages){
|
||||
|
||||
List<(int, string)> response = new List<(int, string)>();
|
||||
|
||||
for_each_enumerate(get_hexas_from(code), (hexa, i) => {
|
||||
for_each_enumerate(code, (hexa, i) => {
|
||||
for(byte j = 0; j < power && (hexa & 1 << j) <= hexa; j ++)
|
||||
if((hexa & 1 << j) != 0){
|
||||
|
||||
@ -161,34 +198,66 @@ namespace ErrorsManager{
|
||||
return response.ToArray();
|
||||
}
|
||||
|
||||
public int get_bits(object code){
|
||||
if(code is string _string)
|
||||
return _string.Length == 0 ? 0 : (_string.Length - 1) * power + (int)Math.Ceiling(Math.Log2(dictionary[_string.Last<char>()] + 1));
|
||||
if(code is byte[] array)
|
||||
return array.Length == 0 ? 0 : (array.Length - 1) * power + (int)Math.Ceiling(Math.Log2(array.Last<byte>() + 1));
|
||||
if(code is int integer)
|
||||
return (int)Math.Ceiling(Math.Log2(integer + 1));
|
||||
return 0;
|
||||
public (int, string)[] process(int code, IEnumerable<string> messages){
|
||||
return process(to_array(code), messages);
|
||||
}
|
||||
|
||||
public T bitwise<T>(T code, int bits){
|
||||
if(code is string _string)
|
||||
return (T)(object)to_string(bitwise<byte[]>(to_array(_string), bits));
|
||||
if(code is byte[] array){
|
||||
public int get_bits(string code){
|
||||
return code.Length == 0 ? 0 : (code.Length - 1) * power + (int)Math.Ceiling(Math.Log2(dictionary[code.Last<char>()] + 1));
|
||||
}
|
||||
|
||||
byte shift;
|
||||
int mask;
|
||||
List<byte> hexas;
|
||||
public int get_bits(byte[] code){
|
||||
return code.Length == 0 ? 0 : (code.Length - 1) * power + (int)Math.Ceiling(Math.Log2(code.Last<byte>() + 1));
|
||||
}
|
||||
|
||||
public int get_bits(int code){
|
||||
return (int)Math.Ceiling(Math.Log2(code + 1));
|
||||
}
|
||||
|
||||
public string clean(string code){
|
||||
|
||||
int l = code.Length;
|
||||
|
||||
while(l > 0 && code[l - 1] == alphabet[0])
|
||||
l --;
|
||||
|
||||
return (
|
||||
code.Length == l ? code :
|
||||
l == 0 ? alphabet[0].ToString() :
|
||||
code.Substring(0, l));
|
||||
}
|
||||
|
||||
public byte[] clean(byte[] code){
|
||||
|
||||
int l = code.Length;
|
||||
|
||||
while(l > 0 && code[l - 1] == 0)
|
||||
l --;
|
||||
|
||||
return (
|
||||
l == code.Length ? code :
|
||||
l == 0 ? new byte[]{0} :
|
||||
code.Take(l).ToArray<byte>());
|
||||
}
|
||||
|
||||
public int clean(int code){
|
||||
return code;
|
||||
}
|
||||
|
||||
public string bitwise(string code, int bits){
|
||||
return to_string(bitwise(to_array(code), bits));
|
||||
}
|
||||
public byte[] bitwise(byte[] code, int bits){
|
||||
if(code.Length == 0 || bits == 0)
|
||||
return code;
|
||||
|
||||
byte shift = (byte)(Math.Abs(bits) % power);
|
||||
int mask = _base - 1;
|
||||
List<byte> hexas = code.ToList<byte>();
|
||||
|
||||
if(bits < 0){
|
||||
if(array.Length < (int)((bits *= -1) / power))
|
||||
return (T)(object)new byte[]{0};
|
||||
|
||||
shift = (byte)(bits % power);
|
||||
mask = _base - 1;
|
||||
hexas = array.ToList<byte>();
|
||||
|
||||
hexas.RemoveRange(0, (int)(bits / power));
|
||||
hexas.RemoveRange(0, (int)(-bits / power));
|
||||
|
||||
if(shift != 0 && hexas.Count != 0){
|
||||
|
||||
@ -200,42 +269,41 @@ namespace ErrorsManager{
|
||||
|
||||
}
|
||||
|
||||
return (T)(object)hexas.ToArray<byte>();
|
||||
};
|
||||
if(bits > 0){
|
||||
|
||||
shift = (byte)(bits % power);
|
||||
mask = _base - 1;
|
||||
hexas = array.ToList<byte>();
|
||||
}else{
|
||||
|
||||
if(shift != 0){
|
||||
|
||||
int last_hexa = hexas[hexas.Count - 1] << shift;
|
||||
|
||||
for(int i = hexas.Count - 1; i > 0; i --)
|
||||
hexas[i] = (byte)((hexas[i] << shift) | ((hexas[i - 1] >> (power - shift)) & mask));
|
||||
hexas[i] = (byte)(((hexas[i] << shift) & mask) | (hexas[i - 1] >> (power - shift)));
|
||||
hexas[0] = (byte)((hexas[0] << shift) & mask);
|
||||
|
||||
if(last_hexa >= _base)
|
||||
hexas.Add((byte)(last_hexa >> power));
|
||||
|
||||
}
|
||||
|
||||
for(int i = bits / power; i > 0; i --)
|
||||
hexas.Insert(0, 0);
|
||||
|
||||
return (T)(object)hexas.ToArray<byte>();
|
||||
}
|
||||
return (T)(object)array;
|
||||
}
|
||||
if(code is int integer)
|
||||
return (T)(object)(
|
||||
bits > 0 ? integer << bits :
|
||||
bits < 0 ? integer >> -bits :
|
||||
integer);
|
||||
return code;
|
||||
}
|
||||
|
||||
public void get_from_bits(object code, ref int from, ref int bits){
|
||||
return clean(hexas.ToArray<byte>());
|
||||
}
|
||||
|
||||
public int bitwise(int code, int bits){
|
||||
return (
|
||||
bits > 0 ? code << bits :
|
||||
bits < 0 ? code >> -bits :
|
||||
code);
|
||||
}
|
||||
|
||||
public void get_from_bits(string code, ref int from, ref int bits){
|
||||
get_from_bits(to_array(code), ref from, ref bits);
|
||||
}
|
||||
|
||||
public void get_from_bits(byte[] code, ref int from, ref int bits){
|
||||
if(from < 0){
|
||||
from = get_bits(code) + from;
|
||||
if(from < 0)
|
||||
@ -251,21 +319,24 @@ namespace ErrorsManager{
|
||||
}
|
||||
}
|
||||
|
||||
public T reset<T>(T code, int from, int bits = 0, bool reversed = false){
|
||||
if(bits == 0 || (from == 0 && bits < 0))
|
||||
return code;
|
||||
if(code is string _string)
|
||||
return (T)(object)to_string(reset<byte[]>(to_array(_string), from, bits, reversed));
|
||||
if(code is byte[] array){
|
||||
public void get_from_bits(int code, ref int from, ref int bits){
|
||||
get_from_bits(to_array(code), ref from, ref bits);
|
||||
}
|
||||
|
||||
List<byte> hexas = array.ToList<byte>();
|
||||
public string reset(string code, int from, int bits = 0, bool reversed = false){
|
||||
return to_string(reset(to_array(code), from, bits, reversed));
|
||||
}
|
||||
|
||||
public byte[] reset(byte[] code, int from, int bits = 0, bool reversed = false){
|
||||
|
||||
List<byte> hexas = code.ToList<byte>();
|
||||
int hexa_from;
|
||||
int hexa_to;
|
||||
int l;
|
||||
byte from_mask;
|
||||
byte to_mask;
|
||||
|
||||
get_from_bits(array, ref from, ref bits);
|
||||
get_from_bits(code, ref from, ref bits);
|
||||
hexa_from = (int)(from / power);
|
||||
hexa_to = (int)((from + bits) / power);
|
||||
|
||||
@ -304,65 +375,158 @@ namespace ErrorsManager{
|
||||
}
|
||||
}
|
||||
|
||||
return (T)(object)hexas.ToArray<byte>();
|
||||
return hexas.ToArray<byte>();
|
||||
}
|
||||
if(code is int integer){
|
||||
|
||||
get_from_bits(integer, ref from, ref bits);
|
||||
public int reset(int code, int from, int bits = 0, bool reversed = false){
|
||||
|
||||
return (T)(object)(integer & (reversed ?
|
||||
get_from_bits(code, ref from, ref bits);
|
||||
if(from + bits > 31)
|
||||
bits = 31 - from;
|
||||
|
||||
return code & (reversed ?
|
||||
~-(1 << bits) << from :
|
||||
(~-(1 << get_bits(integer)) << from + bits) | ~-(1 << from)));
|
||||
}
|
||||
return code;
|
||||
(~-(1 << get_bits(code)) << from + bits) | ~-(1 << from));
|
||||
|
||||
}
|
||||
|
||||
public T get_range<T>(T code, int from, int length = 0){
|
||||
if(code is string _string)
|
||||
return to_string(get_range(to_array(_string), length));
|
||||
if(code is byte[] array){
|
||||
public string get_range(string code, int from, int bits = 0){
|
||||
return to_string(get_range(to_array(code), from, bits));
|
||||
}
|
||||
|
||||
List<byte> hexas = new List<byte>();
|
||||
public byte[] get_range(byte[] code, int from, int bits = 0){
|
||||
|
||||
List<byte> hexas;
|
||||
|
||||
get_from_bits(code, ref from, ref bits);
|
||||
|
||||
if(bits == 0)
|
||||
bits = get_bits(code) - from;
|
||||
if(bits <= 0)
|
||||
return new byte[]{0};
|
||||
|
||||
hexas = code.ToList<byte>();
|
||||
|
||||
if(from > 0){
|
||||
|
||||
byte shift = (byte)(from % power);
|
||||
int mask = ~-_base;
|
||||
|
||||
hexas.AddRange(array.Take(from / power));
|
||||
if(shift != 0){
|
||||
for(int i = hexas.Count - 2; i >= 0; i --)
|
||||
hexas = hexas.Skip(from / power).ToList<byte>();
|
||||
if(shift != 0 && hexas.Count > 0){
|
||||
|
||||
int l = hexas.Count - 1;
|
||||
for(int i = 0; i < l; i ++)
|
||||
hexas[i] = (byte)((hexas[i] >> shift) | ((hexas[i + 1] << (power - shift)) & mask));
|
||||
hexas[hexas.Count - 1] = (byte)(hexas.Last<byte>() >> shift);
|
||||
hexas[hexas.Count - 1] >>= shift;
|
||||
}
|
||||
|
||||
}
|
||||
if(length > 0){
|
||||
if(bits > 0){
|
||||
|
||||
byte shift = (byte)(length % power);
|
||||
byte shift = (byte)(bits % power);
|
||||
|
||||
hexas = hexas.Take<byte>((int)Math.Ceiling(bits / (double)power)).ToList<byte>();
|
||||
if(shift != 0 && hexas.Count > 0)
|
||||
hexas[hexas.Count - 1] &= (byte)((1 << shift) - 1);
|
||||
|
||||
hexas.Take<byte>((int)Math.Ceiling(hexas.Count / (double)power));
|
||||
if(shift != 0)
|
||||
hexas[hexas.Count - 1] = (byte)(hexas.Last<byte>() & ~-(1 << shift));
|
||||
}
|
||||
|
||||
return to_integer(array.Skip(from / power).Take((int)Math.Ceiling((length != 0 ? length : get_bits(array) - from) / (double)power)).ToArray<byte>());
|
||||
return clean(hexas.ToArray<byte>());
|
||||
}
|
||||
if(code is int integer)
|
||||
return (from > 0 ? integer >> from : integer) & (length > 0 ? ~(-1 << length) : integer);
|
||||
|
||||
public int get_range(int code, int from, int bits = 0){
|
||||
|
||||
get_from_bits(code, ref from, ref bits);
|
||||
|
||||
if(from > 0)
|
||||
code = (code >> from) & ((1 << (31 - from)) - 1);
|
||||
|
||||
if(bits <= 0 || bits >= 31)
|
||||
return code;
|
||||
|
||||
if(from + bits > 31)
|
||||
bits = 31 - from;
|
||||
|
||||
return code & ((1 << bits) - 1);
|
||||
}
|
||||
|
||||
public bool has(Error code, int? bits = null){
|
||||
return code switch{
|
||||
Error.String _string => _string.value.ToList<char>().Take<byte>(get_hexas_from_bits(bits)).Length * power > bits,
|
||||
Error.Array array => array.value.ToList<byte>().Take<byte>(Math.Ceiling(Math.Log2(bits))).Where<byte>(hexa => hexa != 0).Count<byte>() != 0,
|
||||
Error.Integer integer => (bits != null && bits != 0 ? ~-(1 << bits) & integer.value : integer.value) != 0,
|
||||
_ => false
|
||||
};
|
||||
public bool has(string code, int from = 0, int bits = 0){
|
||||
foreach(char character in get_range(code, from, bits))
|
||||
if(character != alphabet[0])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<string> get_keys(object? items){
|
||||
public bool has(byte[] code, int from = 0, int bits = 0){
|
||||
foreach(byte hexa in get_range(code, from, bits))
|
||||
if(hexa != 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool has(int code, int from = 0, int bits = 0){
|
||||
return get_range(code, from, bits) != 0;
|
||||
}
|
||||
|
||||
public string set(string error, string code, int _from = 0, int bits = 0){
|
||||
return to_string(set(to_array(error), to_array(code), _from, bits));
|
||||
}
|
||||
|
||||
public string set(string error, byte[] code, int _from = 0, int bits = 0){
|
||||
return to_string(set(to_array(error), code, _from, bits));
|
||||
}
|
||||
|
||||
public string set(string error, int code, int _from = 0, int bits = 0){
|
||||
return to_string(set(to_array(error), to_array(code), _from, bits));
|
||||
}
|
||||
|
||||
public byte[] set(byte[] error, string code, int _from = 0, int bits = 0){
|
||||
return set(error, to_array(code), _from, bits);
|
||||
}
|
||||
|
||||
public byte[] set(byte[] error, byte[] code, int _from = 0, int bits = 0){
|
||||
|
||||
int l;
|
||||
int m = error.Length;
|
||||
int n = code.Length;
|
||||
List<byte> results = new List<byte>();
|
||||
|
||||
if(bits != 0)
|
||||
error = reset(error, _from, bits);
|
||||
if(_from != 0)
|
||||
n = (code = bitwise(code, _from)).Length;
|
||||
l = m > n ? m : n;
|
||||
|
||||
for(int i = 0; i < l; i ++)
|
||||
results.Add((byte)(
|
||||
(i < m ? error[i] : (byte)0) | (i < n ? code[i] : (byte)0)
|
||||
));
|
||||
|
||||
return clean(results.ToArray<byte>());
|
||||
}
|
||||
|
||||
public byte[] set(byte[] error, int code, int _from = 0, int bits = 0){
|
||||
return set(error, to_array(code), _from, bits);
|
||||
}
|
||||
|
||||
public int set(int error, string code, int _from = 0, int bits = 0){
|
||||
return to_integer(set(error, to_integer(code), _from, bits));
|
||||
}
|
||||
|
||||
public int set(int error, byte[] code, int _from = 0, int bits = 0){
|
||||
return to_integer(set(error, to_integer(code), _from, bits));
|
||||
}
|
||||
|
||||
public int set(int error, int code, int _from = 0, int bits = 0){
|
||||
if(bits != 0)
|
||||
error = reset(error, _from, bits);
|
||||
if(_from != 0)
|
||||
code = bitwise(code, _from);
|
||||
return error | code;
|
||||
}
|
||||
|
||||
public static List<string> get_keys(object items){
|
||||
|
||||
List<string> keys = new List<string>();
|
||||
|
||||
@ -373,8 +537,8 @@ namespace ErrorsManager{
|
||||
foreach(string item_i in strings)
|
||||
if(!keys.Contains(item_i) && RE_KEY.IsMatch(item_i))
|
||||
keys.Add(item_i);
|
||||
}else if(items is IEnumerable<object?> list)
|
||||
foreach(object? item in list){
|
||||
}else if(items is IEnumerable<object> list)
|
||||
foreach(object item in list){
|
||||
if(item == null)
|
||||
continue;
|
||||
if(item is string string_item){
|
||||
@ -389,27 +553,27 @@ namespace ErrorsManager{
|
||||
return keys;
|
||||
}
|
||||
|
||||
public static List<Dictionary<string, object?>> get_dictionaries(object? items){
|
||||
public static List<Dictionary<string, object>> get_dictionaries(object items){
|
||||
|
||||
List<Dictionary<string, object?>> dictionaries = new List<Dictionary<string, object?>>();
|
||||
List<Dictionary<string, object>> dictionaries = new List<Dictionary<string, object>>();
|
||||
|
||||
if(items is Dictionary<string, object?> dictionary)
|
||||
if(items is Dictionary<string, object> dictionary)
|
||||
dictionaries.Add(dictionary);
|
||||
else if(items is IEnumerable<object?> list)
|
||||
foreach(object? item in list)
|
||||
else if(items is IEnumerable<object> list)
|
||||
foreach(object item in list)
|
||||
dictionaries.AddRange(get_dictionaries(item));
|
||||
|
||||
return dictionaries;
|
||||
}
|
||||
|
||||
public static T? get<T>(object keys, object? dictionaries, T? _default = default(T?)){
|
||||
public static T get<T>(object keys, object dictionaries, T _default = default(T)){
|
||||
|
||||
List<string> keys_list = get_keys(keys);
|
||||
|
||||
if(keys_list.Count != 0)
|
||||
foreach(Dictionary<string, object?> dictionary in get_dictionaries(dictionaries))
|
||||
foreach(Dictionary<string, object> dictionary in get_dictionaries(dictionaries))
|
||||
foreach(string key in keys_list)
|
||||
if(dictionary.TryGetValue(key, out object? value) && value is T typed)
|
||||
if(dictionary.TryGetValue(key, out object value) && value is T typed)
|
||||
return typed;
|
||||
return _default;
|
||||
}
|
||||
|
||||
@ -1,23 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- <OutputType>Library</OutputType> -->
|
||||
<TargetFrameworks>net10.0;net462</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- <Nullable>enable</Nullable> -->
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<RootNamespace>AnP</RootNamespace>
|
||||
<AssemblyName>AnP</AssemblyName>
|
||||
<RootNamespace>ErrorsManager</RootNamespace>
|
||||
<AssemblyName>ErrorsManager</AssemblyName>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||
<Compile Include="ErrorsManager.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Tests.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
3
CSharp/ErrorsManager.slnx
Normal file
3
CSharp/ErrorsManager.slnx
Normal file
@ -0,0 +1,3 @@
|
||||
<Solution>
|
||||
<Project Path="ErrorsManager.csproj" />
|
||||
</Solution>
|
||||
@ -2,12 +2,17 @@ using System;
|
||||
|
||||
namespace ErrorsManager{
|
||||
class Program{
|
||||
public static void Main(string[] args){
|
||||
|
||||
static void Main(string[] args){
|
||||
|
||||
Console.WriteLine("Hello World!");
|
||||
|
||||
}
|
||||
// Tests.errors();
|
||||
// Tests.conversions();
|
||||
// Tests.alphabet();
|
||||
// Tests.bitwise();
|
||||
// Tests.bitwise_sucesive();
|
||||
// Tests.bits();
|
||||
// Tests.reset();
|
||||
Tests.ranges();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
241
CSharp/Tests.cs
Normal file
241
CSharp/Tests.cs
Normal file
@ -0,0 +1,241 @@
|
||||
using System;
|
||||
|
||||
namespace ErrorsManager{
|
||||
|
||||
class FullError{
|
||||
|
||||
public int integer;
|
||||
public string _string;
|
||||
public byte[] array;
|
||||
|
||||
public FullError(ErrorsManager errors, int integer){
|
||||
this.integer = integer;
|
||||
_string = errors.to_string(integer);
|
||||
array = errors.to_array(integer);
|
||||
}
|
||||
|
||||
public FullError(ErrorsManager errors, string _string){
|
||||
integer = errors.to_integer(_string);
|
||||
this._string = _string;
|
||||
array = errors.to_array(_string);
|
||||
}
|
||||
|
||||
public FullError(ErrorsManager errors, byte[] array){
|
||||
integer = errors.to_integer(array);
|
||||
_string = errors.to_string(array);
|
||||
this.array = array;
|
||||
}
|
||||
|
||||
public static string print(byte[] array){
|
||||
return "[" + string.Join(", ", array) + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Tests{
|
||||
|
||||
public static void errors(){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager();
|
||||
FullError error = new FullError(errors, 217934237);
|
||||
FullError reset = new FullError(errors, 0);
|
||||
|
||||
reset.integer = errors.reset(error.integer, -5, 12);
|
||||
reset._string = errors.reset(error._string, -5, 12);
|
||||
reset.array = errors.reset(error.array, -5, 12);
|
||||
|
||||
Console.WriteLine($"RESET: from {-5} bits {12}");
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(error.integer)} - {errors.to_string_binary(reset.integer)}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(error._string)} - {errors.to_string_binary(reset._string)}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(error.array)} - {errors.to_string_binary(reset.array)}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
public static ErrorsManager conversions(int tests = 10, object inputs = null){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager(inputs);
|
||||
Random seed = new Random();
|
||||
|
||||
for(int i = 0; i < tests; i ++){
|
||||
|
||||
FullError error = new FullError(errors, seed.Next(0, 1 << 16));
|
||||
|
||||
Console.WriteLine($"INTEGER: {errors.to_integer(error.integer)}, {errors.to_integer(error._string)}, {errors.to_integer(error.array)}");
|
||||
Console.WriteLine($"STRING: {errors.to_string(error.integer)}, {errors.to_string(error._string)}, {errors.to_string(error.array)}");
|
||||
Console.WriteLine($"ARRAY: {FullError.print(errors.to_array(error.integer))}, {FullError.print(errors.to_array(error._string))}, {FullError.print(errors.to_array(error.array))}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
public static void alphabet(int tests = 10){
|
||||
|
||||
Random seed = new Random();
|
||||
|
||||
for(int i = 0; i < tests; i ++){
|
||||
|
||||
ErrorsManager errors = conversions(1, new Dictionary<string, object>() {
|
||||
{"base", seed.Next(2, 128)}
|
||||
});
|
||||
|
||||
Console.WriteLine($"^^^ ALPHABET: {string.Join(", ", errors.get_alphabet())} ^^^");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void bitwise(int tests = 10){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager();
|
||||
Random seed = new Random();
|
||||
|
||||
for(int i = 0; i < tests; i ++){
|
||||
|
||||
FullError error = new FullError(errors, seed.Next(0, 1 << seed.Next(0, 16)));
|
||||
FullError shifted = new FullError(errors, 0);
|
||||
FullError unshifted = new FullError(errors, 0);
|
||||
int bitwise = 10 - seed.Next(0, 20);
|
||||
|
||||
Console.WriteLine($"BITWISE: {bitwise}");
|
||||
|
||||
shifted.integer = errors.bitwise(error.integer, bitwise);
|
||||
shifted._string = errors.bitwise(error._string, bitwise);
|
||||
shifted.array = errors.bitwise(error.array, bitwise);
|
||||
unshifted.integer = errors.bitwise(shifted.integer, -bitwise);
|
||||
unshifted._string = errors.bitwise(shifted._string, -bitwise);
|
||||
unshifted.array = errors.bitwise(shifted.array, -bitwise);
|
||||
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(error.integer)} - {error.integer}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(error._string)} - {error._string}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(error.array)} - {FullError.print(error.array)}");
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(shifted.integer)} - {shifted.integer}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(shifted._string)} - {shifted._string}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(shifted.array)} - {FullError.print(shifted.array)}");
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(unshifted.integer)} - {unshifted.integer}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(unshifted._string)} - {unshifted._string}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(unshifted.array)} - {FullError.print(unshifted.array)}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void bitwise_sucesive(int tests = 10){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager();
|
||||
FullError error = new FullError(errors, new Random().Next(0, 1 << 16));
|
||||
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(error.integer)} - {error.integer}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(error._string)} - {error._string}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(error.array)} - {FullError.print(error.array)}");
|
||||
Console.WriteLine();
|
||||
|
||||
for(int i = -tests; i < tests; i ++){
|
||||
|
||||
FullError shifted = new FullError(errors, 0);
|
||||
|
||||
Console.WriteLine($"BITWISE: {i}");
|
||||
|
||||
shifted.integer = errors.bitwise(error.integer, i);
|
||||
shifted._string = errors.bitwise(error._string, i);
|
||||
shifted.array = errors.bitwise(error.array, i);
|
||||
|
||||
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(shifted.integer)} - {shifted.integer}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(shifted._string)} - {shifted._string}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(shifted.array)} - {FullError.print(shifted.array)}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void bits(int tests = 10){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager();
|
||||
Random seed = new Random();
|
||||
|
||||
for(int i = 0; i < tests; i++){
|
||||
|
||||
FullError error = new FullError(errors, seed.Next(0, 1 << seed.Next(0, 28)));
|
||||
int from_value = seed.Next(-15, 15);
|
||||
int bits_value = seed.Next(-13, 13);
|
||||
int[] from = new int[]{from_value, from_value, from_value};
|
||||
int[] bits = new int[]{bits_value, bits_value, bits_value};
|
||||
|
||||
errors.get_from_bits(error.integer, ref from[0], ref bits[0]);
|
||||
errors.get_from_bits(error._string, ref from[1], ref bits[1]);
|
||||
errors.get_from_bits(error.array, ref from[2], ref bits[2]);
|
||||
|
||||
|
||||
Console.WriteLine($"CODE: {error.integer} - {error._string} - {FullError.print(error.array)}");
|
||||
Console.WriteLine($"ERROR: {errors.to_string_binary(error.integer)} - {errors.get_bits(error.integer)} - {errors.get_bits(error._string)} - {errors.get_bits(error.array)}");
|
||||
Console.WriteLine($"FROM: {from_value} - {from[0]}, {from[1]}, {from[2]}");
|
||||
Console.WriteLine($"BITS: {bits_value} - {bits[0]}, {bits[1]}, {bits[2]}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void reset(int tests = 10){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager();
|
||||
Random seed = new Random();
|
||||
|
||||
for(int i = 0; i < tests; i ++){
|
||||
|
||||
FullError error = new FullError(errors, seed.Next(0, 1 << 28));
|
||||
int from = seed.Next(-15, 15);
|
||||
int bits = seed.Next(-13, 13);
|
||||
FullError reset = new FullError(errors, 0);
|
||||
|
||||
reset.integer = errors.reset(error.integer, from, bits);
|
||||
reset._string = errors.reset(error._string, from, bits);
|
||||
reset.array = errors.reset(error.array, from, bits);
|
||||
|
||||
Console.WriteLine($"RESET: from {from} bits {bits}");
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(error.integer)} - {errors.to_string_binary(reset.integer)}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(error._string)} - {errors.to_string_binary(reset._string)}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(error.array)} - {errors.to_string_binary(reset.array)}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void ranges(int tests = 10){
|
||||
|
||||
ErrorsManager errors = new ErrorsManager();
|
||||
Random seed = new Random();
|
||||
|
||||
for(int i = 0; i < tests; i ++){
|
||||
|
||||
FullError error = new FullError(errors, seed.Next(0, 1 << 28));
|
||||
int from = seed.Next(-15, 15);
|
||||
int bits = seed.Next(-13, 13);
|
||||
FullError range = new FullError(errors, 0);
|
||||
|
||||
Console.WriteLine($"RANGE: from {from} bits {bits}");
|
||||
errors.get_from_bits(error._string, ref from, ref bits);
|
||||
Console.WriteLine($"REAL: from {from} bits {bits}");
|
||||
|
||||
range.integer = errors.get_range(error.integer, from, bits);
|
||||
range._string = errors.get_range(error._string, from, bits);
|
||||
range.array = errors.get_range(error.array, from, bits);
|
||||
|
||||
Console.WriteLine($"INTEGER: {errors.to_string_binary(error.integer)} - {errors.to_string_binary(range.integer)}");
|
||||
Console.WriteLine($"STRING: {errors.to_string_binary(error._string)} - {errors.to_string_binary(range._string)}");
|
||||
Console.WriteLine($"ARRAY: {errors.to_string_binary(error.array)} - {errors.to_string_binary(range.array)}");
|
||||
Console.WriteLine();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
189
README.md
189
README.md
@ -1,3 +1,190 @@
|
||||
# ErrorsManager
|
||||
|
||||
Errors codes manager for binary errors system, unlocking the 32 bits limit.
|
||||
**ErrorsManager** es una librería que nos permite hacer una gestión de errores mediante códigos de error en base binaria o agrupación de base numérica. La idea es poder trasladar un análisis global de errores entre plataformas de forma simple con el condicionante que ambas plataformas han de conocer estructuralmente el sistema de errores. El propósito de dicho sistema es conseguir un sistema unificado de errores que permita el envío compacto de los mismos evitando un uso innecesario de red.
|
||||
|
||||
# Funcionamiento
|
||||
|
||||
La idea es crear un objeto `ErrorsManager` para gestionar los errores dentro del código y hacer uso de `set`, `has` y `process` para gestionar los errores, aunque de por sí tenga más funcionalidades.
|
||||
|
||||
> **NOTA**: Este manual ordenará los métodos y estructuras conforme su utilidad e importancia fuera del ámbito de la propia librería para uso general.
|
||||
|
||||
## Constructor
|
||||
|
||||
`errors_manager:ErrorsManager = new ErrorsManager(inputs:dict[str, any|null])`
|
||||
|
||||
- **alphabet**: Alfabeto String o Array de Caracteres.
|
||||
- **base**: Entero que representa la máxima base 2 numérica que se usará: 16, 32 o 64, por ejemplo.
|
||||
|
||||
El alfabeto no puede contener caracteres iguales, y si los contiene, se encargará de eliminarlos, reduciendo la posibilidad de base.
|
||||
|
||||
## set
|
||||
|
||||
`error:int = errors_manager.set(from:int, code:int|list[byte]|str, from:int = 0, bits:int = 0)`
|
||||
|
||||
`error:list[byte]= errors_manager.set(from:list[byte], code:int|list[byte]|str, from:int = 0, bits:int = 0)`
|
||||
|
||||
`error:str = errors_manager.set(from:str, code:int|list[byte]|str, from:int = 0, bits:int = 0)`
|
||||
|
||||
1. **error**: Código de error original. Puede ser un String, Array de enteros que representan los Hexas o un entero.
|
||||
2. **code**: Código de error a establecer. Puede ser un String, Array de enteros que representan los Hexas o un entero.
|
||||
3. **from**: Determina si se quiere desplazar `code`. 0 indica que no.
|
||||
4. **bits**: Determina si se pasan a 0 los bits que de `error` desde `from`. 0 indica que no.
|
||||
|
||||
El `from` negativo indica que se cuente desde el final, y el `bits` negativo que se cuente para atrás. Esto se establece desde `ErrorsManager.get_from_bits`.
|
||||
|
||||
Retorna el resultado de la unión de `error` con `code` a partir de las posibles modificaciones de `from` y `bits`.
|
||||
|
||||
## has
|
||||
|
||||
`has:bool = errors_manager.has(code:int|list[byte]|str)`
|
||||
|
||||
Determina si un código de error contiene errores o no.
|
||||
|
||||
## process
|
||||
|
||||
`errors_messages:list[tuple[int, str]] = errors_manager.process(code:int|list[byte]|str, messages:list[str] = [ ... ])`
|
||||
|
||||
Permite recoger el conjunto de mensajes conforme al código de error. Cada mensaje irá acompañado de su Bit de posición, de ahí que retorne una lista de tuplas de un valor entero, que es el Bit de posición; y el String, que es el mensaje en cuestión.
|
||||
|
||||
`[position, message for position:int, message:str in errors_messages]`
|
||||
|
||||
Si retorna una lista vacía es que no hay errores.
|
||||
|
||||
# .NET
|
||||
|
||||
- Docker Hub del SDK: https://hub.docker.com/r/microsoft/dotnet-sdk
|
||||
- Git del SDK: https://github.com/dotnet/sdk
|
||||
|
||||
Para crear los SLN de la Solución:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
|
||||
docker exec -it anp-dotnet bash
|
||||
|
||||
cd CSharp
|
||||
dotnet new sln -n ErrorsManager
|
||||
dotnet sln add ErrorsManager.csproj
|
||||
cd ..
|
||||
|
||||
exit
|
||||
|
||||
sudo chown -R root:$USER CSharp/ErrorsManager.slnx
|
||||
|
||||
```
|
||||
|
||||
Luego hay que pelar el archivo de definición de proyecto `ErrorsManager.csproj`:
|
||||
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<!-- <OutputType>Library</OutputType> -->
|
||||
<TargetFrameworks>net10.0;net462</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>ErrorsManager</RootNamespace>
|
||||
<AssemblyName>ErrorsManager</AssemblyName>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ErrorsManager.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Tests.cs" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
Instalación del SDK para desarrollo VSCode.
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
|
||||
sudo dpkg -i packages-microsoft-prod.deb
|
||||
rm packages-microsoft-prod.deb
|
||||
sudo apt update
|
||||
sudo apt install -y dotnet-sdk-10.0
|
||||
```
|
||||
|
||||
Luego, instalar el Pluggin Nuget de Visual Studio Code `C/C++ DevTools`.
|
||||
|
||||
Para ejecutar un proyecto .NET desde Docker.
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
docker exec -it anp-dotnet dotnet run --project /workspace/CSharp/ErrorsManager.csproj -f net10.0
|
||||
```
|
||||
|
||||
Para compilar DLL primero configurar el archivo de definición de proyecto `ErrorsManager.csproj`.
|
||||
|
||||
```xml
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<!-- <OutputType>Exe</OutputType> -->
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFrameworks>net10.0;net462</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>ErrorsManager</RootNamespace>
|
||||
<AssemblyName>ErrorsManager</AssemblyName>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ErrorsManager.cs" />
|
||||
<!-- <Compile Include="Program.cs" />
|
||||
<Compile Include="Tests.cs" /> -->
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
Y luego ejecutar:
|
||||
|
||||
```sh
|
||||
#!/bin/bash
|
||||
dotnet build ErrorsManager.csproj -c Release
|
||||
```
|
||||
|
||||
# Objetivos
|
||||
|
||||
Leyenda:
|
||||
|
||||
- **Py**: Python
|
||||
- **PHP**
|
||||
- **JS**: JavaScript/ECMAScript
|
||||
- **MSL**: SQLServer/TransactSQL
|
||||
- **MyL**: MySQL/MariaDB
|
||||
- **CS**: C#/CSharp
|
||||
- **VB**: VisualBasic
|
||||
- **Go**: Golang
|
||||
- **RS**: Rust
|
||||
- **C**
|
||||
- **CPP**: C++
|
||||
|
||||
Tabla de objetivos:
|
||||
|
||||
| Objetivo | Py | PHP | JS | MSL | MyS | CS | VB | Go | RS | C | CPP |
|
||||
|-------------------|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|
|
||||
| Common base | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| set_alphabet | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| get_alphabet | [ ] | [ ] | [ ] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| to_array | [X] | [ ] | [X] | | | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| to_integer | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| to_string | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| to_string_binary | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| process | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| get_bits | [ ] | [ ] | [ ] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| bitwise | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| get_from_bits | [ ] | [ ] | [ ] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| reset | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| get_range | [ ] | [ ] | [ ] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| has | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| clean | [ ] | [ ] | [ ] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
| set | [X] | [ ] | [X] | [ ] | [ ] | [X] | [ ] | [ ] | [ ] | [ ] | [ ] |
|
||||
|
||||
> **NOTA**: Los Checkbox indican el estado siendo los siguientes:
|
||||
|
||||
- [ ] Sin cubrir, está por hacerse.
|
||||
- [-] Están en desarrollo actualmente.
|
||||
- [X] Ya está hecho y es usable.
|
||||
|
||||
> **NOTA**: Según lenguajes que tenga cierta rigidez, como es el caso de Golang, los nombres de los métodos y atributos pueden cambiar a Camel o Pascal.
|
||||
Loading…
Reference in New Issue
Block a user