Recent

Author Topic: What is the SHELL command called now ?  (Read 2337 times)

dryzone

  • Jr. Member
  • **
  • Posts: 60
What is the SHELL command called now ?
« on: February 25, 2025, 05:21:23 am »
I could not find a Linux section, so I would assume the Unix section in the fpk forum is the correct place to post Linux questions. Please correct me if I am wrong.

I have a lot of very old free pascal programs that I need to get working with a newer compiler.

The programs compiled  with  ppc386  Ver 2.0   contains shell commands e.g.
SHELL('cat foo.dat > bar.dat');

What is the upgraded command for SHELL as using  ppcx64 version 3.2.2    exits with SHELL unrecognized

Error: Identifier not found "SHELL"

dsiders

  • Hero Member
  • *****
  • Posts: 1472
Re: What is the SHELL command called now ?
« Reply #1 on: February 25, 2025, 06:18:38 am »
I could not find a Linux section, so I would assume the Unix section in the fpk forum is the correct place to post Linux questions. Please correct me if I am wrong.

I have a lot of very old free pascal programs that I need to get working with a newer compiler.

The programs compiled  with  ppc386  Ver 2.0   contains shell commands e.g.
SHELL('cat foo.dat > bar.dat');

What is the upgraded command for SHELL as using  ppcx64 version 3.2.2    exits with SHELL unrecognized

Error: Identifier not found "SHELL"

https://wiki.freepascal.org/Executing_External_Programs
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

dryzone

  • Jr. Member
  • **
  • Posts: 60
Re: What is the SHELL command called now ?
« Reply #2 on: February 25, 2025, 06:48:20 am »
Yes but it does not address what the new unit is called that would allow my  SHELL  commands to execute.
It will be brutal to change all the SHELL commands to these routines as in the manual.
One command SHELL now seemingly became an entire sub program as replacement.
A regression.

So is the following example that was working in 2.0 now obsolete ?
 SHELL('cat foo.dat > bar.dat');

If so, so much for backward compatibility in fpk.
« Last Edit: February 25, 2025, 06:49:52 am by dryzone »

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: What is the SHELL command called now ?
« Reply #3 on: February 25, 2025, 07:07:51 am »
...
A regression.

So is the following example that was working in 2.0 now obsolete ?
 SHELL('cat foo.dat > bar.dat');

If so, so much for backward compatibility in fpk.

From the page that dsiders linked:
Quote
Linux.Shell/Unix.Shell was an 1.0.x equivalent to fpsystem with less narrowly defined error handling, and after a decade of deprecation it was finally removed. In nearly all cases it can be replaced by fpsystem that features more POSIX like errorhandling.
So, yeah. Sometimes things get deprecated and in the end removed.
Today is tomorrow's yesterday.

dryzone

  • Jr. Member
  • **
  • Posts: 60
Re: What is the SHELL command called now ?
« Reply #4 on: February 25, 2025, 07:26:52 am »
fpSystem is seemingly not a unit as is professed to replace shell commands.

"Fatal: Can't find unit fpSystem used by Program"

So it seems I will have to write my own unit  to execute all the SHELL commands in my programs.
I will continue doing that then.

Backward compatibility would  have been trivial to include, but somehow not.
It is now up to the user to rewrite all their programs after a new fpk version is released. Not good.
My programs are large and contains a lot of SHELL, and I used them to write several papers in Physics.
Now I have to go rewrite them and risk errors to be introduced in perfectly working programs.
So I will have to spend months testing again, just because fpk does not have a backward compatibility policy. Hate to move to Fortran, but it seems to be the prudent move as a broken backward compatibility policy in fpk, will bite me yet again in the future.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: What is the SHELL command called now ?
« Reply #5 on: February 25, 2025, 07:30:27 am »
fpsystem, put cursor on the that word and press F1 or lmddgtfy
Today is tomorrow's yesterday.

dryzone

  • Jr. Member
  • **
  • Posts: 60
Re: What is the SHELL command called now ?
« Reply #6 on: February 25, 2025, 07:59:03 am »
I know that.
Point is the fpFunction should have been a built in unit, which it is not.
I will write a unit as a plaster to the lack of backward compatibility.
It is all I can do, but it will cost me a month of testing again.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: What is the SHELL command called now ?
« Reply #7 on: February 25, 2025, 08:50:17 am »
Point is the fpFunction should have been a built in unit, which it is not.
I am completely puzzled by that statement so I must be misunderstanding something there.

fpSystem is merely a function of the unix unit. The remark seem to suggest that you want it to be a function of the standard system RTL.

The latter makes no sense for non unix platforms, f.e. a windows user would have no use for it just as a linux user would have no use whatsoever for f.e. the function WinExec or createprocess (which are part of shellapi).

Quote
I will write a unit as a plaster to the lack of backward compatibility.
It is all I can do, but it will cost me a month of testing again.
Create a function named shell that has the same proto-typing that the original shell function used to have and invoke fpsystem instead. At least the wiki suggest it is a replacement for the old shell function so should be able to work as a replacement.
Today is tomorrow's yesterday.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12536
  • FPC developer.
Re: What is the SHELL command called now ?
« Reply #8 on: February 25, 2025, 09:32:37 am »
fpSystem is merely a function of the unix unit. The remark seem to suggest that you want it to be a function of the standard system RTL.

Pass -Fabaseunix ?

P.s. this changed happened in 2003. It is now 2025.

TRon

  • Hero Member
  • *****
  • Posts: 4377
Re: What is the SHELL command called now ?
« Reply #9 on: February 25, 2025, 09:37:37 am »
That is a nice solution/suggestion marcov. That did not even crossed my mind.
Today is tomorrow's yesterday.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12536
  • FPC developer.
Re: What is the SHELL command called now ?
« Reply #10 on: February 25, 2025, 09:44:48 am »
It is a trick usually used by e.g. ISO Pascal dialect users to bring in non standard system unit functions and built-ins from their previous compiler into default view.

Shell() was in the 1.0.x Linux unit, and available in 2.0.x in unit oldlinux, but that was 32-bit only and stopped being packaged starting with 3.0 in 2015 or so.
« Last Edit: February 25, 2025, 09:46:20 am by marcov »

dryzone

  • Jr. Member
  • **
  • Posts: 60
Re: What is the SHELL command called now ?
« Reply #11 on: February 26, 2025, 11:55:51 pm »
The correct answer to the question would have simply been.

1) Add  unit "Unix"
2) Replace SHELL with  fpSystem in the code.

Easy as that, yet a few bothered.

Thanks to all that answered, I appreciate the few answers that were to the point. I managed to solve it myself, with some pointers from a few of the answers which were directly on topic.

Problem Solved
« Last Edit: February 26, 2025, 11:58:33 pm by dryzone »

 

TinyPortal © 2005-2018