Created
September 4, 2024 19:42
-
-
Save jonasbn/00c42291e2ea19f5742d7fdbe90e1904 to your computer and use it in GitHub Desktop.
Simple helper script in my path to add files to .gitignore, creating it if it does not already exist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
my $file = '.gitignore'; | |
if (-e $file and -f _ and -w _) { | |
open my $FOUT, '>>', $file or die "Unable to open file: $file - $!"; | |
print $FOUT "$ARGV[0]\n"; | |
close($FOUT); | |
} else { | |
open my $FOUT, '>>', $file or die "Unable to open file: $file - $!"; | |
print $FOUT "$ARGV[0]\n"; | |
close($FOUT); | |
} | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment