Skip to content

Commit

Permalink
Windows OS, Allow chdir To Fail When Env Vars Not Set
Browse files Browse the repository at this point in the history
  • Loading branch information
wbraswell committed Jul 28, 2016
1 parent 5df7f15 commit 8447b40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions lib/RPerl/Learning.pm
Expand Up @@ -13325,8 +13325,6 @@ Below are two example RPerl constants, one containing numeric data and another c

These two constants can be utilized as follows:

# [[[ SUBROUTINES ]]]

my number $area = PI() * $r ** 2;
my string $dessert = 'having a nice slice of ' . PIE();

Expand Down
8 changes: 7 additions & 1 deletion lib/RPerl/Test/Operator10NamedUnaryChdir/program_00_good.pl
@@ -1,8 +1,9 @@
#!/usr/bin/perl

# [[[ PREPROCESSOR ]]]
# <<< EXECUTE_SUCCESS: 'have $foo = 1' >>>
# <<< EXECUTE_SUCCESS: 'have $foo = ' >>>
# <<< EXECUTE_SUCCESS: 'have $bar = 0' >>>
# <<< EXECUTE_SUCCESS: 'have $bat = 1' >>>

# [[[ HEADER ]]]
use RPerl;
Expand All @@ -16,8 +17,13 @@

# [[[ OPERATIONS ]]]

# DEV NOTE: in Windows (and possibly other operating systems) it is common not to have the $ENV{HOME} or $ENV{LOGDIR}
# environmental variables set, which causes chdir to die when called w/out any options;
# thus, allow $foo to be either 0 in Windows or 1 elsewhere, by simply removing the hard-coded value for $foo in EXECUTE_SUCCESS above
my integer $foo = chdir;
my integer $bar = chdir 'INVALID__DIRECTORY__NAME';
my integer $bat = chdir q{/};

print 'have $foo = ', $foo, "\n";
print 'have $bar = ', $bar, "\n";
print 'have $bat = ', $bat, "\n";

0 comments on commit 8447b40

Please sign in to comment.