The usage is systemx("some_command",@args);. So: my $s1 = capturex 'set', '-eu'; The difference being that command and subsequent arguments must all be passed individually and not in one single string. The way you are calling it, it thinks that the whole string is one single command (and it complains it can't find it).

Ok, so it's clear now that have to tell it to find bash:

my $capture = capturex "bash","2.create.bash", "@ARGV"; $logger->info("capx: $capture");

I got a strong result with wrapping 2.create.bash, which I think is a nifty little utility for my nomenclature scheme.

fritz@laptop:~/Documents/gitlab1$ ./4.wrap.pl 2.millcreek.pl Time is Thu Mar 2 01:43:55 2023 Julian day is 2460005.86383102 ./4.wrap.pl capx: The shebang is specifying bash Using bash 5.0.17(1)-release 2 3 3.millcreek.pl -rwxrwxr-x 1 fritz fritz 11K Mar 2 01:43 3.millcreek.pl fritz@laptop:~/Documents/gitlab1$
HOWEVER! I assume that capturex, systemx and friends spawn a system command directly or via an ephemeral shell which ends as soon as the shell command ends. This means that a sequence of capturex calls will use completely different shells, which will not share any state. So, setting shell options via set -eu on one capturex call will not be preserved on the next capturex call. If you want to preserve state in a shell and execute many shell commands in it there is a simple way: first create a temporary shell script (see tempfile of File::Temp) within your perl-script to contain all the commands you want to run. And then execute this shell script via a single capturex call.

I'm trying to follow, and I have a script to that end:

#!/usr/bin/perl use v5.030; # strictness implied use warnings; use Path::Tiny; my ($path) = @ARGV; if (not defined $path) { die "Need path in\n"; } my $file_in = path("$path"); my @lines = $file_in->lines_utf8; my @matching; for my $line (@lines){ if ( $line =~ /^#*$/){ say "line matched $line"; next; } else { push( @matching, $line ); } } say @matching; say "cardinality: ", scalar @matching; my $target_dir = path('/tmp'); my $tempfile = $target_dir->tempfile('foobarXXXXXX'); $tempfile->spew("@matching"); # not atomic __END__

Output. I can't figure out why the shebang and comments endure:

fritz@laptop:~/Documents/gitlab1$ ./1.wrap.pl 3.git.sh line matched #!/bin/bash pwd >2.txt #echo "starting fresh with rm -rf .git" #rm -rf .git | tee 1.txt #git init #ls >README.md git add *.pl git add *.sh git add *.txt #git remote add origin git@gitlab.com:perlmonks/$1.git git commit -m 'next revision' | tee 2.txt git push -uf origin master | tee 2.txt #git push -uf master main | tee 2.txt cardinality: 13 fritz@laptop:~/Documents/gitlab1$

Question: How is my regex not sieving out the comments? Do you see what I'm trying to pull off here?

Aldebaran++ I have to commend your efforts not only in using Perl but also in using Linux. It's a steep learning curve but it hides a ... springboard at the end of it. Plus the methodical approach you take in achieving your aims.

Woo-hoo, a springboard! If the board is at the height of Skylla, and extends to the center of Charybdis, how long does one fall until impact?

Cheers,


In reply to Re^2: wrapping bash and astronomy by Aldebaran
in thread wrapping bash and astronomy by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.