Skip to content

Commit

Permalink
ooRexxShell: adaptation for the portable version of ooRexx
Browse files Browse the repository at this point in the history
  • Loading branch information
jlfaucher committed May 30, 2024
1 parent a91c4f5 commit 1b20a97
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
2 changes: 1 addition & 1 deletion incubator/ooRexxShell/oorexxshell
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rxapi >/dev/null & # Workaround to avoid crash at first execution
# then ooRexxShell will use a basic parse pull because rlwrap will manage the readline
# otherwise it will use the bash readline.
# A negative histsize means "don't modify the history file". ooRexxShell takes care of the history file.
[ -x "`which rlwrap`" ] && export OOREXXSHELL_RLWRAP="rlwrap --complete-filenames --command-name oorexxshell --histsize -300"
[ -x "`which rlwrap`" ] && export OOREXXSHELL_RLWRAP="rlwrap --no-warnings --complete-filenames --command-name oorexxshell --histsize -300"

# Don't use rlwrap if ooRexxShell is not interactive.
# I don't want the output be polluted by the cleaning of the bracketed paste mode.
Expand Down
33 changes: 23 additions & 10 deletions incubator/ooRexxShell/oorexxshell.rex
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,7 @@ Helpers
::routine loadOptionalComponents
-- Initial customization, before any preloaded package
-- Be silentLoaded when not interactive, to not display a full path which is incompatible with regression tests
call loadPackage .oorexxshell~portableCustomizationFile, /*silentLoaded*/ \ .ooRexxShell~isInteractive, /*silentNotLoaded*/ .true
call loadPackage .oorexxshell~customizationFile, /*silentLoaded*/ \ .ooRexxShell~isInteractive, /*silentNotLoaded*/ .true
-- The routine stringChunks is used internally by ooRexxShell
Expand Down Expand Up @@ -1014,6 +1015,7 @@ Helpers
-- Second customization, after all preloaded packages
-- Be silentLoaded when not interactive, to not display a full path which is incompatible with regression tests
call loadPackage .oorexxshell~portableCustomizationFile2, /*silentLoaded*/ \ .ooRexxShell~isInteractive, /*silentNotLoaded*/ .true
call loadPackage .oorexxshell~customizationFile2, /*silentLoaded*/ \ .ooRexxShell~isInteractive, /*silentNotLoaded*/ .true
if .ooRexxShell~isExtended then do
Expand Down Expand Up @@ -1283,6 +1285,8 @@ Helpers
::attribute maxItemsDisplayed class -- The maximum number of items to display when displaying a collection
::attribute maybeCommand class -- Indicator used during the analysis of the command line
::attribute maybeCommandPrevious class
::attribute portableCustomizationFile class
::attribute portableCustomizationFile2 class
::attribute prompt class -- The prompt to display
::attribute promptAddress class -- .true by default: display the current system address in interpreter[address]
::attribute promptDirectory class -- .true by default: display the prompt directory
Expand Down Expand Up @@ -1391,22 +1395,29 @@ Helpers
self~trapNoValue = .false
self~trapSyntax = .true
HOME = value("HOME",,"ENVIRONMENT") -- probably defined under MacOs and Linux, but maybe not under Windows
if HOME == "" then do
HOMEDRIVE = value("HOMEDRIVE",,"ENVIRONMENT")
HOMEPATH = value("HOMEPATH",,"ENVIRONMENT")
HOME = HOMEDRIVE || HOMEPATH
end
PORTABLE_HOME = value("PACKAGES_HOME",,"ENVIRONMENT") -- will be defined when using a portable version of ooRexx
USER_HOME = value("HOME",,"ENVIRONMENT") -- probably defined under MacOs and Linux, but maybe not under Windows
if USER_HOME == "" then USER_HOME = value("USERPROFILE",,"ENVIRONMENT") -- Windows specific
-- Use a property file to remember the current directory
self~settingsFile = HOME || "/.oorexxshell.ini"
-- if using a portable version then put the setting files there
if PORTABLE_HOME \== "" then self~settingsFile = PORTABLE_HOME || .file~separator || ".oorexxshell.ini"
else self~settingsFile = USER_HOME || .file~separator || ".oorexxshell.ini"
-- When possible, use a history file specific for ooRexxShell
self~historyFile = HOME || "/.oorexxshell_history"
-- For the moment, don't use PORTABLE_HOME because it doesn't work with rlwrap
self~historyFile = USER_HOME || .file~separator || ".oorexxshell_history"
-- Allow customization by end user
self~customizationFile = HOME || "/.oorexxshell_customization.rex"
self~customizationFile2 = HOME || "/.oorexxshell_customization2.rex"
self~portableCustomizationFile = ""
self~portableCustomizationFile2 = ""
if PORTABLE_HOME \== "" then do
self~portableCustomizationFile = PORTABLE_HOME || .file~separator || ".oorexxshell_customization.rex"
self~portableCustomizationFile2 = PORTABLE_HOME || .file~separator || ".oorexxshell_customization2.rex"
end
self~customizationFile = USER_HOME || .file~separator || ".oorexxshell_customization.rex"
self~customizationFile2 = USER_HOME || .file~separator || ".oorexxshell_customization2.rex"
::method hasLastResult class
Expand Down Expand Up @@ -1445,6 +1456,8 @@ Helpers
",[info] isExtended",
",[info] isInteractive",
",[custom] maxItemsDisplayed",
",[info] portableCustomizationFile",
",[info] portableCustomizationFile2",
",[custom] promptAddress",
",[custom] promptDirectory",
",[custom] promptInterpreter",
Expand Down
18 changes: 17 additions & 1 deletion incubator/ooRexxShell/oorexxshell_readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ trap off|on [l[ostdigits]] [nom[ethod]] [nos[tring]] [nov[alue]] [s[yntax]]: dea

Customization
=============
In the HOME directory:
The customization files are searched first in the portable directory (if applicable),
then in the user's home directory. It's possible to define customization files in
both locations.
- The optional file ".oorexxshell_customization.rex" is loaded before any
preloaded package. Typically used for color settings.
- A second optional file ".oorexxshell_customization2.rex" is loaded after all
Expand Down Expand Up @@ -417,6 +419,20 @@ Not sure it's very useful to run HostEmu from THE, but... you see the idea :-)
History of changes
==================

-----------------------------------------------
2024 may 30

Add support for a portable configuration.
When ooRexxShell is executed using a portable version of ooRexx then
- the .ini file is stored in the portable directory.
- the customization files are searched first in the portable directory, then
in the user's home directory. It's possible to define customization files in
both locations.

Note: for the moment, the history file is not stored in the portable directory
because it breaks the history when using rlwrap.


-----------------------------------------------
2024 may 20

Expand Down

0 comments on commit 1b20a97

Please sign in to comment.