Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2019-09-14 Thread Stefan Sperling
On Fri, Sep 06, 2019 at 11:01:35PM +0200, Klemens Nanni wrote:
> Rebased diff that I just tested again on a X230 with athn(4) where I
> installed over an ESSID of the form "Wifi foo" just fine;  empty ESSIDs
> showed up as "" in the list, all others still look normal and could be
> chosen just fine.
> 
> The resulting hostname.athn0 contained
> 
>   nwid 'Wifi foo'
>   dhcp
> 
> I'd like to finally commit this so occasional installations over said
> wifi will just work.
> 
> OK?
> 

Yes please, thanks.

> 
> Index: install.sub
> ===
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1140
> diff -u -p -r1.1140 install.sub
> --- install.sub   21 Aug 2019 17:39:30 -  1.1140
> +++ install.sub   6 Sep 2019 20:19:51 -
> @@ -1171,10 +1171,9 @@ v6_config() {
>  
>  # Perform an 802.11 network scan on interface $1 and cache the result a file.
>  ieee80211_scan() {
> - # N.B. Skipping quoted nwid's for now.
>   [[ -f $WLANLIST ]] ||
>   ifconfig $1 scan |
> - sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
> + sed -n 's/^[[:space:]]*nwid \(.*\) chan [0-9]* bssid 
> \([[:xdigit:]:]*\).*/\1 (\2)/p' >$WLANLIST
>   cat $WLANLIST
>  }
>  
> @@ -1194,12 +1193,12 @@ ieee80211_config() {
>   ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
>   case "$resp" in
>   +([0-9]))
> - _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
> + _nwid=$(ieee80211_scan $_if |
> + sed -n ${resp}'{s/ ([[:xdigit:]:]*)$//p;q;}')
>   [[ -z $_nwid ]] && echo "There is no line $resp."
> + [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
> _nwid=${_nwid%\"}
>   ;;
> - \?) ieee80211_scan $_if |
> - sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
> .*$/   \1 (\2)/p' |
> - cat -n | more -c
> + \?) ieee80211_scan $_if | cat -n | more -c
>   ;;
>   *)  _nwid=$resp
>   ;;
> 



Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2019-09-13 Thread Klemens Nanni
On Fri, Sep 06, 2019 at 11:01:35PM +0200, Klemens Nanni wrote:
> I'd like to finally commit this so occasional installations over said
> wifi will just work.
I'll commit this weekend unless someone objects.



Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2019-09-06 Thread Klemens Nanni
On Tue, Aug 08, 2017 at 11:15:28PM +0200, Klemens Nanni wrote:
> On Tue, Jul 04, 2017 at 10:44:57PM +0200, Klemens Nanni wrote:
> > On Mon, Jul 03, 2017 at 12:45:32AM +0200, Klemens Nanni wrote:
> > > Thanks for looking into it.
> > > 
> > > On Sun, Jul 02, 2017 at 04:32:43PM +, Robert Peichaer wrote:
> > > > ieee80211_scan()
> > > > - Extract the needed information (nwid, bssid) using a very specific
> > > >   sed expression. Any line, not matching this expr is ignored.
> > > > 
> > > > - Remove leading and trailing double-quotes in case of nwids with
> > > >   spaces.
> > > I had the ugly case of an empty SSID in reach while testing this so I
> > > intentionally left double quotes in place within WLANLIST so that
> > > the list presented to the user wouldn't look broken, e.g.
> > >   "my wifi" chan 1 bssid ...
> > >   "" chan 2 bssid ...
> > > as opposed to
> > >   my wifi chan 1 bssid ...
> > >chan 2 bssid ...
> > > 
> > > I'd also leave unqouting to the routine that actually requires it
> > > instead of the function that just provides the list.
> > > 
> > > > - Write nwid and bssid into WLANLIST as '()'.
> > > Writing the simple format directly to cache seems like a good idea
> > > instead of just cutting ^nwid first here and .*$ somewhere else.
> > > 
> > > > ieee80211_config()
> > > > - just print WLANLIST using ieee80211_scan() if the user chooses
> > > >   '?' which has the right format already
> > > > 
> > > > - in case the user selects an entry from WLANLIST using a number,
> > > >   remove the '()' part from the line, resulting in
> > > >   the nwid (without double-quotes)
> > > > 
> > > > - using the quote() function with the ifconfig command ensures,
> > > >   that the nwid is quoted properly with single-quotes in case it
> > > >   contains spaces
> > > This is not needed as "$_nwid" will even work if _nwid='my "wifi'.
> > > 
> > > > - using the quote() function when writing the nwid to the hostname.if
> > > >   files ensures that the nwid is quoted properly with single-quotes
> > > >   in case it contains spaces
> > > > 
> > > > The parse_hn_line() function in netstart does handle quoted nwids
> > > > properly when processing the hostname.if config lines as far as I
> > > > can see.
> > > Yes, it does. But it chokes on SSIDs containing a literal " for example.
> > > 
> > > 
> > > Here is an updated diff taking above considerations into account.
> > > 
> > > Note how ([[:xdigit:]:]*)$ when picking the answer must not be
> > > simplified to (.*)$ as this would fail on SSIDs like "my (hidden) wifi".
> > > 
> > > Feedback/OK?
> > That patch was mangled, sorry. Here it goes again.
> > 
> > Index: install.sub
> > ===
> > RCS file: /cvs/src/distrib/miniroot/install.sub,v
> > retrieving revision 1.1019
> > diff -u -p -r1.1019 install.sub
> > --- install.sub 2 Jul 2017 12:45:43 -   1.1019
> > +++ install.sub 4 Jul 2017 20:43:56 -
> > @@ -1060,10 +1060,9 @@ v6_config() {
> > # Perform an 802.11 network scan on interface $1.
> > # The result is cached in $WLANLIST.
> > ieee80211_scan() {
> > -   # N.B. Skipping quoted nwid's for now.
> > [[ -f $WLANLIST ]] ||
> > ifconfig $1 scan |
> > -   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
> > +   sed -n 's/^[[:space:]]*nwid \(.*\) chan [0-9]* bssid 
> > \([[:xdigit:]:]*\).*/\1 (\2)/p' >$WLANLIST
> > cat $WLANLIST
> > }
> > 
> > @@ -1082,12 +1081,12 @@ ieee80211_config() {
> > ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
> > case "$resp" in
> > +([0-9]))
> > -   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
> > +   _nwid=$(ieee80211_scan $_if |
> > +   sed -n ${resp}'{s/ ([[:xdigit:]:]*)$//p;q;}')
> > [[ -z $_nwid ]] && echo "There is no line $resp."
> > +   [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
> > _nwid=${_nwid%\"}
> > ;;
> > -   \?) ieee80211_scan $_if |
> > -   sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
> > .*$/   \1 (\2)/p' |
> > -   cat -n | more -c
> > +   \?) ieee80211_scan $_if | cat -n | more -c
> > ;;
> > *)  _nwid=$resp
> > ;;
> > 
> Bump. Any progress on this? It still applies to the latest revision.
Rebased diff that I just tested again on a X230 with athn(4) where I
installed over an ESSID of the form "Wifi foo" just fine;  empty ESSIDs
showed up as "" in the list, all others still look normal and could be
chosen just fine.

The resulting hostname.athn0 contained

nwid 'Wifi foo'
dhcp

I'd like to finally commit this so occasional installations over said
wifi will just work.

OK?


Index: install.sub
===
RCS file: 

Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-07-04 Thread Klemens Nanni

On Mon, Jul 03, 2017 at 12:45:32AM +0200, Klemens Nanni wrote:

Thanks for looking into it.

On Sun, Jul 02, 2017 at 04:32:43PM +, Robert Peichaer wrote:

ieee80211_scan()
- Extract the needed information (nwid, bssid) using a very specific
  sed expression. Any line, not matching this expr is ignored.

- Remove leading and trailing double-quotes in case of nwids with
  spaces.

I had the ugly case of an empty SSID in reach while testing this so I
intentionally left double quotes in place within WLANLIST so that
the list presented to the user wouldn't look broken, e.g.
"my wifi" chan 1 bssid ...
"" chan 2 bssid ...
as opposed to
my wifi chan 1 bssid ...
 chan 2 bssid ...

I'd also leave unqouting to the routine that actually requires it
instead of the function that just provides the list.


- Write nwid and bssid into WLANLIST as '()'.

Writing the simple format directly to cache seems like a good idea
instead of just cutting ^nwid first here and .*$ somewhere else.


ieee80211_config()
- just print WLANLIST using ieee80211_scan() if the user chooses
  '?' which has the right format already

- in case the user selects an entry from WLANLIST using a number,
  remove the '()' part from the line, resulting in
  the nwid (without double-quotes)

- using the quote() function with the ifconfig command ensures,
  that the nwid is quoted properly with single-quotes in case it
  contains spaces

This is not needed as "$_nwid" will even work if _nwid='my "wifi'.


- using the quote() function when writing the nwid to the hostname.if
  files ensures that the nwid is quoted properly with single-quotes
  in case it contains spaces

The parse_hn_line() function in netstart does handle quoted nwids
properly when processing the hostname.if config lines as far as I
can see.

Yes, it does. But it chokes on SSIDs containing a literal " for example.


Here is an updated diff taking above considerations into account.

Note how ([[:xdigit:]:]*)$ when picking the answer must not be
simplified to (.*)$ as this would fail on SSIDs like "my (hidden) wifi".

Feedback/OK?

That patch was mangled, sorry. Here it goes again.

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1019
diff -u -p -r1.1019 install.sub
--- install.sub 2 Jul 2017 12:45:43 -   1.1019
+++ install.sub 4 Jul 2017 20:43:56 -
@@ -1060,10 +1060,9 @@ v6_config() {
# Perform an 802.11 network scan on interface $1.
# The result is cached in $WLANLIST.
ieee80211_scan() {
-   # N.B. Skipping quoted nwid's for now.
[[ -f $WLANLIST ]] ||
ifconfig $1 scan |
-   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
+   sed -n 's/^[[:space:]]*nwid \(.*\) chan [0-9]* bssid 
\([[:xdigit:]:]*\).*/\1 (\2)/p' >$WLANLIST
cat $WLANLIST
}

@@ -1082,12 +1081,12 @@ ieee80211_config() {
ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
case "$resp" in
+([0-9]))
-   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
+   _nwid=$(ieee80211_scan $_if |
+   sed -n ${resp}'{s/ ([[:xdigit:]:]*)$//p;q;}')
[[ -z $_nwid ]] && echo "There is no line $resp."
+   [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
_nwid=${_nwid%\"}
;;
-   \?) ieee80211_scan $_if |
-   sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
.*$/   \1 (\2)/p' |
-   cat -n | more -c
+   \?) ieee80211_scan $_if | cat -n | more -c
;;
*)  _nwid=$resp
;;



Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-07-02 Thread Klemens Nanni

Thanks for looking into it.

On Sun, Jul 02, 2017 at 04:32:43PM +, Robert Peichaer wrote:

ieee80211_scan()
 - Extract the needed information (nwid, bssid) using a very specific
   sed expression. Any line, not matching this expr is ignored.

 - Remove leading and trailing double-quotes in case of nwids with
   spaces.

I had the ugly case of an empty SSID in reach while testing this so I
intentionally left double quotes in place within WLANLIST so that
the list presented to the user wouldn't look broken, e.g.
"my wifi" chan 1 bssid ...
"" chan 2 bssid ...
as opposed to
my wifi chan 1 bssid ...
 chan 2 bssid ...

I'd also leave unqouting to the routine that actually requires it
instead of the function that just provides the list.


 - Write nwid and bssid into WLANLIST as '()'.

Writing the simple format directly to cache seems like a good idea
instead of just cutting ^nwid first here and .*$ somewhere else.


ieee80211_config()
 - just print WLANLIST using ieee80211_scan() if the user chooses
   '?' which has the right format already

 - in case the user selects an entry from WLANLIST using a number,
   remove the '()' part from the line, resulting in
   the nwid (without double-quotes)

 - using the quote() function with the ifconfig command ensures,
   that the nwid is quoted properly with single-quotes in case it
   contains spaces

This is not needed as "$_nwid" will even work if _nwid='my "wifi'.


 - using the quote() function when writing the nwid to the hostname.if
   files ensures that the nwid is quoted properly with single-quotes
   in case it contains spaces

The parse_hn_line() function in netstart does handle quoted nwids
properly when processing the hostname.if config lines as far as I
can see.

Yes, it does. But it chokes on SSIDs containing a literal " for example.


Here is an updated diff taking above considerations into account.

Note how ([[:xdigit:]:]*)$ when picking the answer must not be
simplified to (.*)$ as this would fail on SSIDs like "my (hidden) wifi".

Feedback/OK?

I'd say taking nasty characters in $_nwid further into account can be
put into a seperate diff.

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1019
diff -u -p -r1.1019 install.sub
--- install.sub 2 Jul 2017 12:45:43 -   1.1019
+++ install.sub 2 Jul 2017 22:42:38 -
@@ -896,13 +896,14 @@ __EOT
}
@ -1060,10 +1061,9 @@ v6_config() {
# Perform an 802.11 network scan on interface $1.
# The result is cached in $WLANLIST.
ieee80211_scan() {
-   # N.B. Skipping quoted nwid's for now.
[[ -f $WLANLIST ]] ||
ifconfig $1 scan |
-   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
+   sed -n 's/^[[:space:]]*nwid \(.*\) chan [0-9]* bssid 
\([[:xdigit:]:]*\).*/\1 (\2)/p' >$WLANLIST
cat $WLANLIST
}

@@ -1082,12 +1082,12 @@ ieee80211_config() {
ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
case "$resp" in
+([0-9]))
-   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
+   _nwid=$(ieee80211_scan $_if |
+   sed -n ${resp}'{s/ ([[:xdigit:]:]*)$//p;q;}')
[[ -z $_nwid ]] && echo "There is no line $resp."
+   [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
_nwid=${_nwid%\"}
;;
-   \?) ieee80211_scan $_if |
-   sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
.*$/   \1 (\2)/p' |
-   cat -n | more -c
+   \?) ieee80211_scan $_if | cat -n | more -c
;;
*)  _nwid=$resp
;;



Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-07-02 Thread Robert Peichaer
On Thu, Jun 15, 2017 at 12:09:20AM +0200, Klemens Nanni wrote:
> Instead of ignoring SSIDs containing whitespaces, slightly adjust the
> commands to take everything in between 'nwid ' and ' chan' as SSID; if
> it has double quotes at start *and* end, simply remove those.
> 
> This enables users to select networks such as "Unitymedia WifiSpot"
> "FRITZ!Box 7490" for example which are common among the quoted ones at
> least here in germany.
> 
> The only SSIDs known to break this are those containing ' chan ' as this
> substring is used as delimiter. Picking "some chan 4 me" would therefore
> result in _nwid being assigned '"some' (literal double quote), but than
> reasonably acceptable (compared to the current behaviour).
> 
> 
> Since cat's -n flag already takes care of the space between numbers and
> input lines, remove the leading tab to avoid excessive widths for lines
> with long SSIDs.
> 
> Feedback/OK?

I agree, that supporting SSIDs containing whitespaces would be an improvement.

> 
> Index: install.sub
> ===
> RCS file: /cvs/src/distrib/miniroot/install.sub,v
> retrieving revision 1.1014
> diff -u -p -r1.1014 install.sub
> --- install.sub   3 Jun 2017 22:27:41 -   1.1014
> +++ install.sub   14 Jun 2017 22:06:47 -
> @@ -1060,10 +1060,9 @@ v6_config() {
>  # Perform an 802.11 network scan on interface $1.
>  # The result is cached in $WLANLIST.
>  ieee80211_scan() {
> - # N.B. Skipping quoted nwid's for now.
>   [[ -f $WLANLIST ]] ||
>   ifconfig $1 scan |
> - sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
> + sed -n 's/^[[:space:]]*nwid //p' >$WLANLIST
>   cat $WLANLIST
>  }
>  
> @@ -1078,15 +1077,16 @@ ieee80211_config() {
>   # Empty scan cache.
>   rm -f $WLANLIST
>  
> - while [[ -z $_nwid ]]; do
> + while [[ -z "$_nwid" ]]; do
>   ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
>   case "$resp" in
>   +([0-9]))
> - _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
> + _nwid=$(ieee80211_scan $_if | sed -n ${resp}'{s/ chan 
> .*//p;q;}')
>   [[ -z $_nwid ]] && echo "There is no line $resp."
> + [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
> _nwid=${_nwid%\"}
>   ;;
>   \?) ieee80211_scan $_if |
> - sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
> .*$/   \1 (\2)/p' |
> + sed -n 's/^\(.*\) chan .* bssid \([^ ]*\) 
> .*$/\1 (\2)/p' |
>   cat -n | more -c
>   ;;
>   *)  _nwid=$resp

Here's a slightly different but completely untested approach ...

ieee80211_scan()
  - Extract the needed information (nwid, bssid) using a very specific
sed expression. Any line, not matching this expr is ignored.

  - Remove leading and trailing double-quotes in case of nwids with
spaces.

  - Write nwid and bssid into WLANLIST as '()'.

ieee80211_config()
  - just print WLANLIST using ieee80211_scan() if the user chooses
'?' which has the right format already

  - in case the user selects an entry from WLANLIST using a number,
remove the '()' part from the line, resulting in
the nwid (without double-quotes)

  - using the quote() function with the ifconfig command ensures,
that the nwid is quoted properly with single-quotes in case it
contains spaces

  - using the quote() function when writing the nwid to the hostname.if
files ensures that the nwid is quoted properly with single-quotes
in case it contains spaces

The parse_hn_line() function in netstart does handle quoted nwids
properly when processing the hostname.if config lines as far as I
can see.


Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1019
diff -u -p -p -u -r1.1019 install.sub
--- install.sub 2 Jul 2017 12:45:43 -   1.1019
+++ install.sub 2 Jul 2017 16:21:42 -
@@ -1060,10 +1060,10 @@ v6_config() {
 # Perform an 802.11 network scan on interface $1.
 # The result is cached in $WLANLIST.
 ieee80211_scan() {
-   # N.B. Skipping quoted nwid's for now.
[[ -f $WLANLIST ]] ||
ifconfig $1 scan |
-   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
+   sed -En 's/^[[:space:]]+nwid (.*) chan [0-9]+ bssid 
([[:xdigit:]:]+) .*$/\1 (\2)/p' |
+   sed 's/"\(.*\)"/\1/' >$WLANLIST
cat $WLANLIST
 }
 
@@ -1082,12 +1082,11 @@ ieee80211_config() {
ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
case "$resp" in
+([0-9]))
-   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
+   

Re: install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-06-15 Thread Klemens Nanni

No need for quoting $_nwid within [[ ... ]] since field splitting is not
applied.

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -   1.1014
+++ install.sub 15 Jun 2017 14:48:56 -
@@ -1060,10 +1060,9 @@ v6_config() {
# Perform an 802.11 network scan on interface $1.
# The result is cached in $WLANLIST.
ieee80211_scan() {
-   # N.B. Skipping quoted nwid's for now.
[[ -f $WLANLIST ]] ||
ifconfig $1 scan |
-   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
+   sed -n 's/^[[:space:]]*nwid //p' >$WLANLIST
cat $WLANLIST
}

@@ -1082,11 +1081,12 @@ ieee80211_config() {
ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
case "$resp" in
+([0-9]))
-   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
+   _nwid=$(ieee80211_scan $_if | sed -n ${resp}'{s/ chan 
.*//p;q;}')
[[ -z $_nwid ]] && echo "There is no line $resp."
+   [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
_nwid=${_nwid%\"}
;;
\?) ieee80211_scan $_if |
-   sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
.*$/   \1 (\2)/p' |
+   sed -n 's/^\(.*\) chan .* bssid \([^ ]*\) 
.*$/\1 (\2)/p' |
cat -n | more -c
;;
*)  _nwid=$resp



install.sub: ieee80211_{scan,config}: Allow quoted SSIDs

2017-06-14 Thread Klemens Nanni

Instead of ignoring SSIDs containing whitespaces, slightly adjust the
commands to take everything in between 'nwid ' and ' chan' as SSID; if
it has double quotes at start *and* end, simply remove those.

This enables users to select networks such as "Unitymedia WifiSpot"
"FRITZ!Box 7490" for example which are common among the quoted ones at
least here in germany.

The only SSIDs known to break this are those containing ' chan ' as this
substring is used as delimiter. Picking "some chan 4 me" would therefore
result in _nwid being assigned '"some' (literal double quote), but than
reasonably acceptable (compared to the current behaviour).


Since cat's -n flag already takes care of the space between numbers and
input lines, remove the leading tab to avoid excessive widths for lines
with long SSIDs.

Feedback/OK?

Index: install.sub
===
RCS file: /cvs/src/distrib/miniroot/install.sub,v
retrieving revision 1.1014
diff -u -p -r1.1014 install.sub
--- install.sub 3 Jun 2017 22:27:41 -   1.1014
+++ install.sub 14 Jun 2017 22:06:47 -
@@ -1060,10 +1060,9 @@ v6_config() {
# Perform an 802.11 network scan on interface $1.
# The result is cached in $WLANLIST.
ieee80211_scan() {
-   # N.B. Skipping quoted nwid's for now.
[[ -f $WLANLIST ]] ||
ifconfig $1 scan |
-   sed -n 's/^ nwid \([^"]\)/\1/p' >$WLANLIST
+   sed -n 's/^[[:space:]]*nwid //p' >$WLANLIST
cat $WLANLIST
}

@@ -1078,15 +1077,16 @@ ieee80211_config() {
# Empty scan cache.
rm -f $WLANLIST

-   while [[ -z $_nwid ]]; do
+   while [[ -z "$_nwid" ]]; do
ask_until "Access point? (ESSID, 'any', list# or '?')" "any"
case "$resp" in
+([0-9]))
-   _nwid=$(ieee80211_scan $_if | sed -n "${resp}s/ .*//p")
+   _nwid=$(ieee80211_scan $_if | sed -n ${resp}'{s/ chan 
.*//p;q;}')
[[ -z $_nwid ]] && echo "There is no line $resp."
+   [[ $_nwid = \"*\" ]] && _nwid=${_nwid#\"} 
_nwid=${_nwid%\"}
;;
\?) ieee80211_scan $_if |
-   sed -n 's/^\([^ ]*\) chan .* bssid \([^ ]*\) 
.*$/   \1 (\2)/p' |
+   sed -n 's/^\(.*\) chan .* bssid \([^ ]*\) 
.*$/\1 (\2)/p' |
cat -n | more -c
;;
*)  _nwid=$resp