Skip to content

Commit

Permalink
fix getting wifi ssid on ubuntu
Browse files Browse the repository at this point in the history
on ubuntu and probably other systems, /bin/sh does not support `-o pipefail`

closes greshake#280
  • Loading branch information
mathroc committed Oct 8, 2018
1 parent 192274f commit c247c65
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/blocks/net.rs
Expand Up @@ -95,11 +95,8 @@ impl NetworkDevice {
.args(
&[
"-c",
"-o",
"pipefail",
&format!(
"iw dev {} link | grep \"^\\sSSID:\" | sed \"s/^\\sSSID:\\s//g\" || nmcli -g general.connection device show {}",
self.device,
"iw dev {} link | grep \"^\\sSSID:\" | sed \"s/^\\sSSID:\\s//g\"",
self.device
),
],
Expand All @@ -108,6 +105,22 @@ impl NetworkDevice {
.block_error("net", "Failed to execute SSID query.")?
.stdout;

if iw_output.len() == 0 {
mut iw_output = Command::new("sh")
.args(
&[
"-c",
&format!(
"nmcli -g general.connection device show {}",
self.device
),
],
)
.output()
.block_error("net", "Failed to execute SSID query.")?
.stdout;
}

if iw_output.len() == 0 {
Ok(None)
} else {
Expand Down

0 comments on commit c247c65

Please sign in to comment.