Checking env under f33

is one user out here running F33 (or lesser then F34) ?

if yes:
please do me an favor and test the following script and please report

#!/bin/bash

echo -e "\n PWD is: $PWD";
echo -e "\n pwd is: $(pwd)";
echo -e "\n";

env|grep -i pwd && read

please put it somewhere under an sub directory in $HOME, but not $HOME it’s self and start it with nautilus.
use “CRTL+c” to end the script

Background:
under F34 when I start the script laying under, let’s say, /home/<username>/Download/
the path or the working directory it returns is always only /home/<username> and not /home/<username>/Download/ where the script was started from.

1 Like

The default Nautilus settings on F33 prohibit running executables.
We need to allow it and redirect stdout to a log to be able to see the output.
As a result, all commands return the path matching the location of the script.

2 Likes

thanks, that was what I want to know, cause this is no more the case under F34.

so output directed via “… > ./…” in an scripts always goes to /home/<user> and not to the location of the script.
e.g.
echo otto > ./mylog writes the file mylog to /home/<user>/mylog

1 Like

You can use something like this to work around the issue:

echo "${0%/*}"
echo "$(dirname "${0}")"
1 Like

no, doesn’t work (in any case) e.g. in this one:

#!/bin/bash

#set -vx;

WHEREIAM="$(dirname "${0}")";

echo ${WHEREIAM} && read

rm -rfv ${WHEREIAM}/fstrim_last_run_*;

sudo su -c '

DISKs="$(echo /dev/sd?) $(echo /dev/nvme?)";

   sync && sync && sync;

   echo -e "\nrunning fstrim for: ${DISKs}, wait ...\n";

   echo -e "\ntrimed ${DISKs}:\n" > ${WHEREIAM}/fstrim_last_run_$(date +%F);

   fstrim -va >> ${WHEREIAM}/fstrim_last_run_$(date +%F);
   RC=$?;
   echo -e "\n\ntrim-RC=${RC}" >> ${WHEREIAM}/fstrim_last_run_$(date +%F);

   echo -e "\n\nHealth checking:" >> ${WHEREIAM}/fstrim_last_run_$(date +%F);

   for i in ${DISKs}
   do
      echo -e "\n${i}" >> ${WHEREIAM}/fstrim_last_run_$(date +%F);
      smartctl -H ${i} | grep overall-health >> ${WHEREIAM}/fstrim_last_run_$(date +%F);
   done;

   chown ron.ron ${WHEREIAM}/fstrim_last_run_$(date +%F);
';

geany ${WHEREIAM}/fstrim_last_run_$(date +%F);

in line 4 it works correct, but after that the output goes to / (root !!!).

I guess no one need such an feature or is willing to change all her/his scripts.
anyway I opened a bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=1945933

1 Like

You can expand variables/commands beforehand, or simply preserve the current environment:

sudo -i << EOI
...
EOI

sudo -E -s << "EOI"
...
EOI

thanks for you further encouragement.

but to me this manner how nautilus works now regarding $PWD under F34 seems to be a really serious BUG !

not that a user need to change all her/his scripts, in its worste case it has dangerous side effects e.g. mistakenly writing or deleting under / .

a few moments ago I lost the directory where the script was in (had a backup though), but …
hell no

1 Like

it’s fixed with a new nautilus-40.1-2