mirror of
https://github.com/UzixLS/picocom.git
synced 2025-07-19 07:21:18 +03:00
Comments, some renames, nimor quoting fix
This commit is contained in:
@ -5,20 +5,14 @@
|
|||||||
# Or arrange for it to be sourced by your ".bashrc",
|
# Or arrange for it to be sourced by your ".bashrc",
|
||||||
# Or copy it in /etc/bash_completion.d (it will be sourced automatically)
|
# Or copy it in /etc/bash_completion.d (it will be sourced automatically)
|
||||||
#
|
#
|
||||||
# The idea is to provide simple custom completions for options names
|
# The idea is to provide simple custom completions for option names
|
||||||
# and options values, while keeping the standard ones (variable,
|
# and option values, while keeping the standard ones (variable,
|
||||||
# pathname, etc) if the custom ones don't produce matches. It does not
|
# pathname, etc) if the custom ones don't produce matches. This script
|
||||||
# depend on the "bash-completion" package (just plain bash) and it
|
# does not depend on the "bash-completion" package (just plain bash)
|
||||||
# does not use any of its helper functions.
|
# and it does not use any of its helper functions.
|
||||||
#
|
#
|
||||||
# The code is not bullet-proof; you *can* confuse it with strange
|
# The code is not bullet-proof; you *can* confuse it with strange
|
||||||
# input if you try. There is also a known issue with giving option
|
# input if you try.
|
||||||
# values like this:
|
|
||||||
#
|
|
||||||
# --option="value" or --option='value'
|
|
||||||
#
|
|
||||||
# That is, with an equal *and* within quotes. The solution is also
|
|
||||||
# known. For simplicty, though, I decided not to include it.
|
|
||||||
#
|
#
|
||||||
# See also:
|
# See also:
|
||||||
# Bash mapage (man bash)
|
# Bash mapage (man bash)
|
||||||
@ -36,7 +30,8 @@
|
|||||||
#
|
#
|
||||||
# by Nick Patavalis (npat@efault.net)
|
# by Nick Patavalis (npat@efault.net)
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
# the Free Software Foundation; either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
@ -51,7 +46,7 @@
|
|||||||
# USA
|
# USA
|
||||||
#
|
#
|
||||||
|
|
||||||
# _npat_split_line
|
# _picocom_split_line
|
||||||
#
|
#
|
||||||
# Splits line into words. Line is split in almost exatcly the same way
|
# Splits line into words. Line is split in almost exatcly the same way
|
||||||
# as readline does it. Using this function, you can specify your own
|
# as readline does it. Using this function, you can specify your own
|
||||||
@ -67,8 +62,7 @@
|
|||||||
# either by delimiter characters (which do not appear in the resulting
|
# either by delimiter characters (which do not appear in the resulting
|
||||||
# word-straem) or by separator characters, which do.
|
# word-straem) or by separator characters, which do.
|
||||||
#
|
#
|
||||||
#
|
function _picocom_split_line()
|
||||||
function _npat_split_line()
|
|
||||||
{
|
{
|
||||||
local delimiters=$' \t\n'
|
local delimiters=$' \t\n'
|
||||||
local separators=$'='
|
local separators=$'='
|
||||||
@ -204,7 +198,7 @@ _picocom_dequote()
|
|||||||
for (( i=0; i<${#quoted}; i++ )); do
|
for (( i=0; i<${#quoted}; i++ )); do
|
||||||
c=${quoted:i:1}
|
c=${quoted:i:1}
|
||||||
c1=${quoted:i+1:1}
|
c1=${quoted:i+1:1}
|
||||||
#echo " [$c] [$c1] [$inside]"
|
#echo " [$c] [$c1] [$inside]" > $DEBUG
|
||||||
if [[ -z $inside ]]; then
|
if [[ -z $inside ]]; then
|
||||||
if [[ $c == '\' ]]; then
|
if [[ $c == '\' ]]; then
|
||||||
let i++
|
let i++
|
||||||
@ -288,7 +282,7 @@ _picocom()
|
|||||||
mappings=( crlf crcrlf igncr lfcr lfcrlf ignlf delbs bsdel \
|
mappings=( crlf crcrlf igncr lfcr lfcrlf ignlf delbs bsdel \
|
||||||
spchex tabhex crhex lfhex 8bithex nrmhex )
|
spchex tabhex crhex lfhex 8bithex nrmhex )
|
||||||
|
|
||||||
_npat_split_line
|
_picocom_split_line
|
||||||
cur="${words[-1]}"
|
cur="${words[-1]}"
|
||||||
prev="${words[-2]}"
|
prev="${words[-2]}"
|
||||||
#cur="${COMP_WORDS[COMP_CWORD]}"
|
#cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
@ -323,8 +317,8 @@ _picocom()
|
|||||||
-I | --imap | -O | --omap | -E | --emap )
|
-I | --imap | -O | --omap | -E | --emap )
|
||||||
[[ "$cur" =~ ^[\'\"]?[A-Za-z0-9,\ \\]*[\'\"]?$ ]] || return 0
|
[[ "$cur" =~ ^[\'\"]?[A-Za-z0-9,\ \\]*[\'\"]?$ ]] || return 0
|
||||||
_picocom_filter_mappings
|
_picocom_filter_mappings
|
||||||
cur1="${cur##*[, ]}"
|
cur1=${cur##*[, ]}
|
||||||
cur0="${cur%$cur1}"
|
cur0=${cur%"$cur1"}
|
||||||
echo "$cur0 | $cur1 |" > $DEBUG
|
echo "$cur0 | $cur1 |" > $DEBUG
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
COMPREPLY=( $(compgen -P "$cur0" -S "," -W "${mapfilt[*]}" -- "$cur1") )
|
COMPREPLY=( $(compgen -P "$cur0" -S "," -W "${mapfilt[*]}" -- "$cur1") )
|
||||||
|
Reference in New Issue
Block a user