Chromium Code Reviews| Index: bin/crosh |
| diff --git a/bin/crosh b/bin/crosh |
| index 6bbb92a00f115c8dcc24b03392525cddd7a50283..9dc88627c3589df11a999c6dae38c02e98e2d379 100755 |
| --- a/bin/crosh |
| +++ b/bin/crosh |
| @@ -21,10 +21,6 @@ else |
| IS_BASH=0 |
| fi |
| -# The terminal seems to come up with a bogus notion of its geometry. Calling |
| -# reset works around the problem. |
| -reset |
|
Daniel Erat
2011/01/28 22:36:53
This shouldn't be needed now that we're using rxvt
rginda
2011/02/02 23:07:43
Cool, that reset took forever.
|
| - |
| if [ "$TRY_BASH" = "1" -a "$IS_BASH" != "1" -a -x "/bin/bash" ]; then |
| # Relaunch in bash if we can. |
| exec /bin/bash $0 "$@" |
| @@ -45,7 +41,7 @@ HELP=' |
| enterprise_ca_disapprove |
| Remove a previously approved enterprise certificate authority. |
| - |
| + |
| exit |
| Exit crosh. |
| @@ -59,7 +55,7 @@ HELP=' |
| Interact with the 3G modem. Run "modem help" for detailed help. |
| network_logging <wifi | cellular | ethernet> |
| - A function that enables a predefined set of tags useful for |
| + A function that enables a predefined set of tags useful for |
| debugging the specified device. |
| network_diag |
| @@ -176,7 +172,7 @@ cmd_ssh() { |
| if [ -z "$host" ]; then |
| echo "Missing required parameter: host" |
| return |
| - elif ! check_hostname "$host"; then |
| + elif ! check_hostname "$host" && ! check_ipv6 "$host"; then |
| echo "Invalid host: $host" |
| return |
| fi |
| @@ -285,11 +281,11 @@ cmd_network_logging(){ |
| echo; /usr/bin/wpa_debug msgdump |
| ;; |
| "cellular") |
| - echo; /usr/bin/ff_debug service+modem+device+manager |
| - echo; /usr/bin/wpa_debug info |
| + echo; /usr/bin/ff_debug service+modem+device+manager |
| + echo; /usr/bin/wpa_debug info |
| ;; |
| "ethernet") |
| - echo; /usr/bin/ff_debug service+ethernet+device+manager |
| + echo; /usr/bin/ff_debug service+ethernet+device+manager |
| echo; /usr/bin/wpa_debug info |
| ;; |
| "--help") |
| @@ -451,10 +447,18 @@ dispatch() { |
| fi |
| } |
| -# Checks that a given string starts with an alphanumeric, and contains only |
| -# alphanumeric, '.' or '-' characters |
| +# Checks that a given string looks like a hostname or IPv4 address (starts |
| +# with an alphanumeric and contains only alphanumeric, '.', or '-' |
| +# characters). |
| check_hostname() { |
| - expr "$1" : '^[[:alnum:]][[:alnum:].\-]*$' > /dev/null |
| + expr "$1" : '^[[:alnum:]][-[:alnum:].]*$' > /dev/null |
| +} |
| + |
| +# Checks that a given string could plausibly be an IPv6 address |
| +# (hexadecimal, ':', and '.' characters only, followed by an optional zone |
| +# index consisting of a '%' and a device name). |
| +check_ipv6() { |
| + echo "$1" | /bin/grep -E -q '^[0-9a-fA-F:.]+(%[a-z0-9]+)?$' |
|
Daniel Erat
2011/01/28 22:36:53
I finally gave up on expr's poorly-documented regu
|
| } |
| # Checks that a given string starts with an alphanumeric, and contains only |