Saving value as default value

Hi everybody,

I have a prog who is filtering an image with a lot of parameters. The user has two choices :

-Running the script with default values

-Running the script manually (i.e choosing himself the parameters values)

What I would like to do is that if he wants, the users can keep the values he chose as new default values.
WIth stg like a question : "Do you want to keep those values as default? [Y/N]"

And the problem is that I have no idea how to do that....

So if anyone could help me, i'll be very grateful!

Thanks

Are you stuck on how to accept the user's option or how to save the default parameters per user ?

To accept the user's option see one of these

If you are wondering how to save the parameters, then accept the params for the first time and then dump them onto a file with <key,value> pair like
RUN_ALGO=YES
TRANSFORM=NO et al.
Later, in the next run, look for this file and read the entries.

I was stuck to save values.
Thx for your answers!

Using personal setup file ex. mysetup.txt. This works every posix-sh (ksh, bash, ...).

#!/bin/ksh
#mysetup
#use:
#mysetup -
#- use mysetup using my own defaut setup
#or
#mysetup
#- ask values and save using previous values as default

set1="sysdefault1"
set2="sysdefault2"
# always use mysetup as default if there is
[ -f $HOME/mysetup.txt ] && . $HOME/mysetup.txt

savedef()
{
   > $HOME/mysetup.txt
   # which variables to save
   for var in set1 set2
   do
        eval echo "\"$var='\$$var'\""  >> $HOME/mysetup.txt
   done
}

askvalues()
{
echo -n "set1 [$set1]:"
read Xset1
[ "$Xset1" != "" ] && set1="$Xset1"
echo -n "set2 [$set2]:"
read Xset2
[ "$Xset2" != "" ] && set2="$Xset2"
savedef
}

#######MAIN####
[ "$1" != "-" ] && askvalues

thx a lot for your answer :slight_smile: