English Amiga Board


Go Back   English Amiga Board > Support > support.AmigaOS

 
 
Thread Tools
Old 26 October 2023, 16:08   #1
tomcat666
Retro Freak
 
tomcat666's Avatar
 
Join Date: Nov 2001
Location: Slovenia
Age: 51
Posts: 1,647
AmigaDOS problems with scripting and double quotes

Hi

We are trying to do a whdload launcher that would use a database to get all the options and then execute a script that in the end actually launches WHDLoad. The script is used so that people can customize it as they want.
However we have problem with parsing the double quotes " inside the script. On OS 3.2 it seems to be working fine when we use the substituon (escaping) of " with *" , example (ECHO "$TT" is the correct usage) :



But when the same code is run on 3.1 we get this:



And no usage will work.

Is there any way to use this on OS 3.1 in scripting ?

btw. the actual line CONFIG="aaa;ccc" nocache is passed over to the script using a WHDARGS parameter which is gotten with this key:

.key FOLDER,SLAVE/A,WNC/S,WEC/S,NOTURBO/S,NFC/S,SC/S,ICNT/N,MHZ/N,WHD/K,WHDARGS/F
tomcat666 is offline  
Old 26 October 2023, 16:37   #2
patrik
Registered User
 
patrik's Avatar
 
Join Date: Jan 2005
Location: UmeƄ
Age: 43
Posts: 924
Out of curiosity, is the content of the TT env identical in 3.2 and 3.1? You should be able to view it with the GetEnv command.
patrik is offline  
Old 26 October 2023, 16:38   #3
thomas
Registered User
 
thomas's Avatar
 
Join Date: Jan 2002
Location: Germany
Posts: 7,001
Interesting. I first tried with "aaa;ccc" only. Then the result is the other way round, with quotes I got the full string, without it was truncated at the ;

Anyway, this seems to be a bug of the Echo command. Use getenv instead.

And BTW, for simple variables you should use set/get instead of setenv/getenv. SetEnv is only useful to save global settings. Or if there is no other possibility than to write to a variable with >env:xxx
thomas is offline  
Old 26 October 2023, 17:02   #4
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,180
never actually tried before but can amigaos use single quotes in place of doubles like you can in linux scripts where you are able to mix/match them?
DisasterIncarna is offline  
Old 26 October 2023, 17:04   #5
hooverphonique
ex. demoscener "Bigmama"
 
Join Date: Jun 2012
Location: Fyn / Denmark
Posts: 1,624
Quote:
Originally Posted by DisasterIncarna View Post
never actually tried before but can amigaos use single quotes in place of doubles like you can in linux scripts where you are able to mix/match them?
In shells commonly used on Linux, single and double quotes mean different things, so you can't actually mix and match them.
hooverphonique is offline  
Old 26 October 2023, 17:08   #6
tomcat666
Retro Freak
 
tomcat666's Avatar
 
Join Date: Nov 2001
Location: Slovenia
Age: 51
Posts: 1,647
Quote:
Originally Posted by patrik View Post
Out of curiosity, is the content of the TT env identical in 3.2 and 3.1? You should be able to view it with the GetEnv command.
Yes, it is the same on both 3.2 and 3.1:

tomcat666 is offline  
Old 26 October 2023, 17:15   #7
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,180
Quote:
Originally Posted by hooverphonique View Post
In shells commonly used on Linux, single and double quotes mean different things, so you can't actually mix and match them.
i probably understand them wrong then, but a few scripts ive made where i use double quotes and i still need to use more quotes ive wrapped doubles in singles. cant think of any example atm except part of this recent one i have lying around.



Code:
  # No PATH Found, add PATH to .bashrc
  echo 'if [ -d "$HOME/.local/bin" ] ; then' >> $HOME/.bashrc
  echo 'PATH="$HOME/.local/bin:$PATH"' >> $HOME/.bashrc
  echo 'fi' >> $HOME/.bashrc
  echo "PATH was not set to check $HOME/.local/bin for scripts/commands, this has been corrected."
  echo "** You need to close this terminal window and re-open for changes to take effect **"
  exit
cant even remember why i had to add single and double quotes (1st line with echo), i think a filename or folder with a space in it most likely made it not work properly without both added in.
DisasterIncarna is offline  
Old 26 October 2023, 17:17   #8
DisasterIncarna
Registered User
 
DisasterIncarna's Avatar
 
Join Date: Oct 2021
Location: England
Posts: 1,180
does the CONFIG= actually need quotes at all? is this specifically for catching spaces?

Also are you trying to get your script to launch WHDLoad and the options normally found in the icon tooltypes? can you not use something like WBRUN to launch the slaves icon which has the options/config for that game and even launches WHDLoad from the project icon?
DisasterIncarna is offline  
Old 26 October 2023, 19:24   #9
tomcat666
Retro Freak
 
tomcat666's Avatar
 
Join Date: Nov 2001
Location: Slovenia
Age: 51
Posts: 1,647
Quote:
Originally Posted by thomas View Post
Interesting. I first tried with "aaa;ccc" only. Then the result is the other way round, with quotes I got the full string, without it was truncated at the ;

Anyway, this seems to be a bug of the Echo command. Use getenv instead.

And BTW, for simple variables you should use set/get instead of setenv/getenv. SetEnv is only useful to save global settings. Or if there is no other possibility than to write to a variable with >env:xxx
Yes, using SET inside my script instead I got it to work. As mentioned here it is an actual bug in the ECHO command, and by not overcomplicating it I got it to work now

Thanx everyone!
tomcat666 is offline  
Old 26 October 2023, 19:24   #10
tomcat666
Retro Freak
 
tomcat666's Avatar
 
Join Date: Nov 2001
Location: Slovenia
Age: 51
Posts: 1,647
Quote:
Originally Posted by DisasterIncarna View Post
does the CONFIG= actually need quotes at all? is this specifically for catching spaces?

Also are you trying to get your script to launch WHDLoad and the options normally found in the icon tooltypes? can you not use something like WBRUN to launch the slaves icon which has the options/config for that game and even launches WHDLoad from the project icon?
Yes, CONFIG needs quotes because of the ; character inside... it doesn't need them only if used as ToolType.

WBRun doesn't come into play because the script is used by the wrapper which must work with both CLI and ICON start...
tomcat666 is offline  
Old 26 October 2023, 22:31   #11
Thomas Richter
Registered User
 
Join Date: Jan 2019
Location: Germany
Posts: 3,233
Quote:
Originally Posted by thomas View Post
Anyway, this seems to be a bug of the Echo command. Use getenv instead.

The "echo" command does surprisingly little. This sounds more like a defect (one of many) of the 3.1 shell. What likely happens is that the shell blindly expands the variable, removes the quotes and then puts the result into the shell parser. The ";" in the middle of the string is then read by the remaining shell parser as introduction of a comment, and stripped off.
Thomas Richter is offline  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
AmigaDOS scripting resources Photon Coders. System 26 19 March 2018 14:51
Amiga Game Speeches and Quotes. cebulba Nostalgia & memories 22 06 March 2016 17:31
AmigaDOS 1.3 Scripting Language redblade Coders. General 10 16 August 2008 12:58
Team 17 CD32 Double Pack problems! Mrk support.WinUAE 4 12 March 2007 18:42
Crazy Wacky Non Understandable game quotes Fred the Fop Nostalgia & memories 5 23 February 2004 11:02

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 15:29.

Top

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Page generated in 0.11926 seconds with 15 queries