Skip to content

Commit

Permalink
Fix glob for serial device names
Browse files Browse the repository at this point in the history
Removing the "." that was in {,.[0-9]} allows it to match /dev/cuau10 and onward.
I added lots of comments on the glob expression, because the format of the glob expression is not the same as an ordinary regex.
  • Loading branch information
Phil Davis committed Jul 14, 2015
1 parent 82921c7 commit cc4d136
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion usr/local/www/interfaces_ppps_edit.php
Expand Up @@ -484,7 +484,12 @@ interface_ppps_configure($pppif);
mwexec("/bin/mkdir -p /var/spool/lock");
}
// $serialports = pfSense_get_modem_devices();
$serialports = glob("/dev/cua?[0-9]{,.[0-9]}", GLOB_BRACE);
// Match files in /dev starting with "cua" then:
// ? = any single character e.g. like "cuau"
// [0-9] = a digit from 0 to 9
// {,[0-9]} = nothing (the empty before the comma) or a digit from 0 to 9
// This supports up to 100 devices (0 to 99), e.g. cuau0 cuau1 ... cuau10 cuau11 ... cuau99
$serialports = glob("/dev/cua?[0-9]{,[0-9]}", GLOB_BRACE);
$serport_count = 0;
foreach ($serialports as $port) {
$serport_count++;
Expand Down

0 comments on commit cc4d136

Please sign in to comment.