Recent

Author Topic: Are there any bash like instructions for lazarus pascal?  (Read 3229 times)

guest48704

  • Guest
Are there any bash like instructions for lazarus pascal?
« on: December 06, 2019, 04:56:10 pm »
I am amazed that there are not any bash like instructions for the high level languages like pascal and C.  Bash instructions, such as sed, grep, awk are extremely powerful for manipulating data.  With pascal, I have to mickey mouse around with several instructions to get the same results that can be done with one or two bash instructions.  Am I missing something with the higher languages?  There is something called JCL, but I don't know if it still exist and if JCL has data manipulating instructions.

winni

  • Hero Member
  • *****
  • Posts: 1817
Re: Are there any bash like instructions for lazarus pascal?
« Reply #1 on: December 06, 2019, 05:36:11 pm »
Hi!

There is runcommand, shellexecute and and and ....

So build your own library to make it happen!

Winni

MarkMLl

  • Hero Member
  • *****
  • Posts: 1244
Re: Are there any bash like instructions for lazarus pascal?
« Reply #2 on: December 06, 2019, 05:49:56 pm »
I am amazed that there are not any bash like instructions for the high level languages like pascal and C.  Bash instructions, such as sed, grep, awk are extremely powerful for manipulating data.

sed, grep and the rest are absolutely nothing to do with Bash. If you want everything muddled together into a single program then use Perl (it's what I do when the job in hand merits it).

Now, having got that out of the way what /exactly/ are you complaining about? What are you actually trying to do? Do you really need extra facilities built into the language, or is your problem that you're having to run under Windows and find yourself missing a few binaries you're used to?

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8734
  • FPC developer.
Re: Are there any bash like instructions for lazarus pascal?
« Reply #3 on: December 06, 2019, 06:02:15 pm »
FPC has multiple regex libraries (sorokins regexpr) and various PCRE headers are available.

Bash is a shell, and not every executable that Bash can execute (including AWK, SED, TR etc) is bash functionality.

A lot is possible in real languages (being Pascal, but also e.g. C), but forget about shell script knowledge. That is a different (and very slow) world.

guest48704

  • Guest
Re: Are there any bash like instructions for lazarus pascal?
« Reply #4 on: December 06, 2019, 06:32:22 pm »
I am amazed that there are not any bash like instructions for the high level languages like pascal and C.  Bash instructions, such as sed, grep, awk are extremely powerful for manipulating data.

sed, grep and the rest are absolutely nothing to do with Bash. If you want everything muddled together into a single program then use Perl (it's what I do when the job in hand merits it).

Now, having got that out of the way what /exactly/ are you complaining about? What are you actually trying to do? Do you really need extra facilities built into the language, or is your problem that you're having to run under Windows and find yourself missing a few binaries you're used to?

MarkMLl

I was counting on some condescending, arrogant, accusatory answers like yours.

guest48704

  • Guest
Re: Are there any bash like instructions for lazarus pascal?
« Reply #5 on: December 06, 2019, 06:35:31 pm »
FPC has multiple regex libraries (sorokins regexpr) and various PCRE headers are available.

Bash is a shell, and not every executable that Bash can execute (including AWK, SED, TR etc) is bash functionality.

A lot is possible in real languages (being Pascal, but also e.g. C), but forget about shell script knowledge. That is a different (and very slow) world.

  This is more of the civil answer I was hoping for.  Do you know of any website that explains  the FPC has multiple regex libraries?

Thanks

Handoko

  • Hero Member
  • *****
  • Posts: 3775
  • My goal: build my own game engine using Lazarus
Re: Are there any bash like instructions for lazarus pascal?
« Reply #6 on: December 06, 2019, 06:37:13 pm »

MarkMLl

  • Hero Member
  • *****
  • Posts: 1244
Re: Are there any bash like instructions for lazarus pascal?
« Reply #7 on: December 06, 2019, 06:43:17 pm »
I was counting on some condescending, arrogant, accusatory answers like yours.

And I was counting on somebody complaining about the language to at least tell us what operating system he was using >:-)

Now /what/ are you trying to do and what shortcomings are you running up against? You're being unfair comparing "Bash" (into which you're rolling at least some of the standard unix textutils) with Pascal and C in the same breath, since at least in the case of Pascal you've got dynamically-allocated strings so you don't have to worry about the memory management that's de rigeur in C. And in recent Pascal implementations you've got various list components, and as others have pointed out you can use regexes in conjunction with lists to do a lot of what grep etc. provide at the command line.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

del

  • Full Member
  • ***
  • Posts: 185
Re: Are there any bash like instructions for lazarus pascal?
« Reply #8 on: December 06, 2019, 07:53:09 pm »
I am amazed that there are not any bash like instructions for the high level languages like pascal and C.  Bash instructions, such as sed, grep, awk are extremely powerful for manipulating data.  With pascal, I have to mickey mouse around with several instructions to get the same results that can be done with one or two bash instructions.  Am I missing something with the higher languages?  There is something called JCL, but I don't know if it still exist and if JCL has data manipulating instructions.

Welcome to the world of real coding.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8734
  • FPC developer.
Re: Are there any bash like instructions for lazarus pascal?
« Reply #9 on: December 06, 2019, 08:42:13 pm »
FPC has multiple regex libraries (sorokins regexpr) and various PCRE headers are available.

Bash is a shell, and not every executable that Bash can execute (including AWK, SED, TR etc) is bash functionality.

A lot is possible in real languages (being Pascal, but also e.g. C), but forget about shell script knowledge. That is a different (and very slow) world.

  This is more of the civil answer I was hoping for.  Do you know of any website that explains  the FPC has multiple regex libraries?


In general I'm not really a regex fan. I generally hardcode the logic in Pascal code if I can. Only if it gets to a complexity that that handcoding threatens to transform into writing an interpreter that I resort to regex. In 20 years that has been a grand total of "1".

In those few cases I use the Sorokin library that is described in Handoko's link. I know from other messages that people that if that is not enough, you can bind the Perl regex library. I never actually reach that level, prefering to reach my goals another way. But binding external libraries is not something I do lightly as my majority target is Windows, and frankly it is generally not worth the (deployment) trouble.

But searching for "pcre delphi" will probably yield some hints.
« Last Edit: December 06, 2019, 08:47:01 pm by marcov »

PascalDragon

  • Hero Member
  • *****
  • Posts: 2151
  • Compiler Developer
Re: Are there any bash like instructions for lazarus pascal?
« Reply #10 on: December 07, 2019, 11:27:25 am »
Bash instructions, such as sed, grep, awk are extremely powerful for manipulating data.
As others already wrote, those are not Bash instructions, but in themselves fullblown C programs that simply abstract all that complicated stuff away to be used on the shell or inside a script. When writing a program you can either execute these commands as well (though the handling of input/output might then be a hassle depending on the usecase) or you simply do everything by foot as in every other language as well (though sometimes there might be rather convient wrappers available).

zamronypj

  • Jr. Member
  • **
  • Posts: 97
    • Fano Framework, Free Pascal web application framework
Re: Are there any bash like instructions for lazarus pascal?
« Reply #11 on: December 07, 2019, 01:53:42 pm »
I am amazed that there are not any bash like instructions for the high level languages like pascal and C.  Bash instructions, such as sed, grep, awk are extremely powerful for manipulating data.  With pascal, I have to mickey mouse around with several instructions to get the same results that can be done with one or two bash instructions.  Am I missing something with the higher languages?  There is something called JCL, but I don't know if it still exist and if JCL has data manipulating instructions.

sed, awk, grep are not bash instructions (what is bash instruction anyway?). They are command line applications. You can create similar application with Free Pascal if you are up to it.
« Last Edit: December 07, 2019, 01:58:28 pm by zamronypj »
Fano Framework, Free Pascal web application framework https://fanoframework.github.io
Personal Projects https://v3.juhara.com
Github https://github.com/zamronypj

winni

  • Hero Member
  • *****
  • Posts: 1817
Re: Are there any bash like instructions for lazarus pascal?
« Reply #12 on: December 07, 2019, 02:06:45 pm »
(what is bash instruction anyway?)

Hi!

bash instructions are the shell builtin commands like test, read and the syntax most used in scripts like if, for, do

Code: Bash  [Select][+][-]
  1. man bash

and then look for the SHELL BUILTIN COMMANDS

Winni

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8734
  • FPC developer.
Re: Are there any bash like instructions for lazarus pascal?
« Reply #13 on: December 07, 2019, 02:21:07 pm »
Note that if you want to mix these shell programs with FPC processing that probably goes fine and simple with FCL-Process'  runcommand. As long as you are on Unix and the files are not too large.

If the files are very large compared to memory  (more than a few tens or hundreds of MBs), it is better to use fcl-process in stream mode, rather than string mode.

lucamar

  • Hero Member
  • *****
  • Posts: 3030
Re: Are there any bash like instructions for lazarus pascal?
« Reply #14 on: December 07, 2019, 02:26:08 pm »
(what is bash instruction anyway?)

As most *nix shells, bash is a programable shell and has a rather advanced built-in "language" of its own (hence the pletora of "shell scripts" used for simple--and not so simple--tasks). The instructions of that language (including the builtin commands) are "bash instructions".

Of course, the OP doesn't seem to be referring to those but to normal commands, i.e. executable programs like any other, including programs written (and compiled) in Pascal :)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.8/FPC 3.0.4 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018