summaryrefslogtreecommitdiffstats
path: root/.local/bin/setwp
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/setwp')
-rwxr-xr-x.local/bin/setwp23
1 files changed, 16 insertions, 7 deletions
diff --git a/.local/bin/setwp b/.local/bin/setwp
index 02241bd..0786461 100755
--- a/.local/bin/setwp
+++ b/.local/bin/setwp
@@ -76,21 +76,30 @@ sub main
{
my $wp;
my $ret;
+ my $arg;
- if (@ARGV != 0 && -f $ARGV[0]) {
- $ret = set_wp($ARGV[0]);
+ $arg = 0;
+ if (@ARGV != 0 && $ARGV[0] eq '-nw') {
+ $arg = 1;
}
- elsif (@ARGV != 0 && -d $ARGV[0]) {
- $wp = choose_wp(get_pool_files($ARGV[0]));
+ if (@ARGV != 0 && -f $ARGV[$arg]) {
+ $ret = set_wp($ARGV[$arg]);
+ }
+ elsif (@ARGV != 0 && -d $ARGV[$arg]) {
+ $wp = choose_wp(get_pool_files($ARGV[$arg]));
$ret = set_wp($wp);
}
else {
$wp = choose_wp(get_pool_files(WP_POOL));
$ret = set_wp($wp);
}
- if (@ARGV == 0 || (@ARGV != 0 && $ARGV[0] ne "-nw")) {
- exec('herbe', ' wp set') if ($ret == 0);
- exec('herbe', ' wp is not a valid file') if ($ret != 0);
+ if (@ARGV == 0 || (@ARGV != 0 && $ARGV[0] ne '-nw')) {
+ my $arg = fork();
+ if (not $arg) {
+ setsid();
+ exec('herbe', ' wp set') if ($ret == 0);
+ exec('herbe', ' wp is not a valid file') if ($ret != 0);
+ }
}
return;
}