Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cd should default to home folder #672

Closed
orefalo opened this issue Jul 31, 2023 · 19 comments
Closed

cd should default to home folder #672

orefalo opened this issue Jul 31, 2023 · 19 comments
Labels
bug Unexpected behavior

Comments

@orefalo
Copy link
Contributor

orefalo commented Jul 31, 2023

Describe the issue:

murex-utils » cd
Error in `cd` (0,1): too few parameters

Expected behaviour:
If the shell is interactive, it should go to the home folder.

@orefalo orefalo added the bug Unexpected behavior label Jul 31, 2023
@lmorg
Copy link
Owner

lmorg commented Jul 31, 2023

Good idea

lmorg added a commit that referenced this issue Jul 31, 2023
@lmorg lmorg linked a pull request Jul 31, 2023 that will close this issue
@orefalo
Copy link
Contributor Author

orefalo commented Aug 10, 2023

this is now fixed in develop, thank you

If I may add one feature to it. a handy shortcut supported by all major shells : cd -

cd - should cd to the previous folder.

in the example below, I should be back into the murex folder

➜  ./murex
Loading profile `.murex_preload`
Loading module `jump/jump`
Loading module `murex-module-jump/jump`
Loading profile `.murex_profile`
murex » cd
~ » cd -
Error in `cd` (0,1): chdir -: no such file or directory
~ »

@lmorg
Copy link
Owner

lmorg commented Aug 10, 2023

I'll get that added

lmorg added a commit that referenced this issue Aug 10, 2023
@lmorg
Copy link
Owner

lmorg commented Aug 10, 2023

update pushed to develop

@orefalo
Copy link
Contributor Author

orefalo commented Aug 10, 2023

Great, thanks for the fast implementation

if I may contribute edge case 1 - it only happens on first c

➜  ./murex
Loading profile `.murex_preload`
Loading module `jump/jump`
Loading module `murex-module-jump/jump`
Loading profile `.murex_profile`
murex » pwd
/Users/orefalo/GitRepositories/murex
murex » cd /
 » pwd
/
 » cd -
Error in `cd` (0,1): already at first directory in $PWDHIST
 »

it should go back to /Users/orefalo/GitRepositories/murex.

so you should probably push the current path to PWDHIST upon initialization

@lmorg
Copy link
Owner

lmorg commented Aug 10, 2023

It does. I cannot replicate this bug on my side. Can you start a new instance of Murex and then, as your first command run $PWDHIST and share the output please

@orefalo
Copy link
Contributor Author

orefalo commented Aug 10, 2023

➜  ./murex
Loading profile `.murex_preload`
Loading module `jump/jump`
Loading module `murex-module-jump/jump`
Loading profile `.murex_profile`
murex » echo $PWDHIST
["/Users/orefalo/GitRepositories/murex"]
murex » cd /tmp
tmp » cd -
Error in `cd` (0,1): already at first directory in $PWDHIST
tmp »

@lmorg
Copy link
Owner

lmorg commented Aug 10, 2023

It's definitely getting initialised then...

Can you run the following after changing directory for the first time please:

runtime --globals -> [PWDHIST]

I wonder if it's not being stored correctly

@orefalo
Copy link
Contributor Author

orefalo commented Aug 11, 2023

Loading profile `.murex_preload`
Loading module `jump/jump`
Loading module `murex-module-jump/jump`
Loading profile `.murex_profile`
murex » runtime --globals -> [PWDHIST]
{
    "DataType": "json",
    "FileRef": {
        "Column": 0,
        "Line": 0,
        "Source": {
            "DateTime": "2023-08-11T07:50:20.437665+02:00",
            "Filename": "(builtin)",
            "Module": "builtin/integrations_zfs_posix"
        }
    },
    "IsInterface": false,
    "Modify": "2023-08-11T07:50:19.54691+02:00",
    "String": "[\"/Users/orefalo/GitRepositories/murex\"]",
    "Value": [
        "/Users/orefalo/GitRepositories/murex"
    ]
}

@lmorg
Copy link
Owner

lmorg commented Aug 11, 2023

How about after you’ve changed directory?

Eg

cd /tmp
runtime --globals -> [PWDHIST]

@orefalo
Copy link
Contributor Author

orefalo commented Aug 11, 2023

murex » cd /tmp
tmp » runtime --globals -> [PWDHIST]
{
    "DataType": "json",
    "FileRef": {
        "Column": 1,
        "Line": 0,
        "Source": {
            "DateTime": "0001-01-01T00:00:00Z",
            "Filename": "",
            "Module": "murex/shell"
        }
    },
    "IsInterface": false,
    "Modify": "2023-08-11T20:01:55.996155+02:00",
    "String": "[\n    \"/private/tmp\"\n]",
    "Value": [
        "/private/tmp"
    ]
}
tmp » cd -
Error in `cd` (0,1): already at first directory in $PWDHIST
tmp » j murex
murex » pwd
/Users/orefalo/GitRepositories/murex
murex » runtime --globals -> [PWDHIST]
{
    "DataType": "json",
    "FileRef": {
        "Column": 204,
        "Line": 1,
        "Source": {
            "DateTime": "2023-08-11T20:01:52.687078+02:00",
            "Filename": "/Users/orefalo/.murex_modules/murex-module-jump/jump.mx",
            "Module": "murex-module-jump/jump"
        }
    },
    "IsInterface": false,
    "Modify": "2023-08-11T20:02:54.891624+02:00",
    "String": "[\n    \"/private/tmp\",\n    \"/Users/orefalo/GitRepositories/murex\"\n]",
    "Value": [
        "/private/tmp",
        "/Users/orefalo/GitRepositories/murex"
    ]
}
murex »

@lmorg
Copy link
Owner

lmorg commented Aug 11, 2023

Interesting. Looks like $PWDHIST is being initialised but then overwritten again the first time you change directory but only the first time. Weird.

Thanks for your patience here. If it's any consolation, I now know where to debug :)

@lmorg
Copy link
Owner

lmorg commented Aug 12, 2023

Getting closer to finding the issue:

~ » cd /
2023/08/12 16:50:14 $PWDHIST has become corrupt ([%!t(string=/home/lau)]) so regenerating

Curious because it's a valid JSON array

» $PWDHIST.0
/home/lau

@lmorg
Copy link
Owner

lmorg commented Aug 12, 2023

Found the problem. fix pushed to develop

@orefalo
Copy link
Contributor Author

orefalo commented Aug 13, 2023

Interesting.. still getting the issue.

➜  ./murex
Loading profile `.murex_preload`
Loading module `free/free`
Loading module `javahome/javahome`
Loading module `jump/jump`
Loading profile `.murex_profile`
murex » runtime --globals -> [PWDHIST]
{
    "DataType": "json",
    "FileRef": {
        "Column": 0,
        "Line": 0,
        "Source": {
            "DateTime": "2023-08-13T04:52:39.149037+02:00",
            "Filename": "(builtin)",
            "Module": "builtin/integrations_zfs_posix"
        }
    },
    "IsInterface": false,
    "Modify": "2023-08-13T04:52:38.17829+02:00",
    "String": "[\"/Users/orefalo/GitRepositories/murex\"]",
    "Value": [
        "/Users/orefalo/GitRepositories/murex"
    ]
}
murex » pwd
/Users/orefalo/GitRepositories/murex
murex » cd /
 » runtime --globals -> [PWDHIST]
{
    "DataType": "json",
    "FileRef": {
        "Column": 1,
        "Line": 0,
        "Source": {
            "DateTime": "0001-01-01T00:00:00Z",
            "Filename": "",
            "Module": "murex/shell"
        }
    },
    "IsInterface": false,
    "Modify": "2023-08-13T04:53:16.548974+02:00",
    "String": "[\n    \"/Users/orefalo/GitRepositories/murex\",\n    \"/\"\n]",
    "Value": [
        "/Users/orefalo/GitRepositories/murex",
        "/"
    ]
}
 » cd -
Error in `cd` (0,1): cannot find previous directory: $PWDHIST doesn't appear to be a valid array
 »

@lmorg
Copy link
Owner

lmorg commented Aug 13, 2023

That'll teach me from releasing code after drinking a few beers 🤦
Just pushed another fix. Give it 10 mins to run through the automated tests before trying though.

@lmorg
Copy link
Owner

lmorg commented Aug 13, 2023

path type documented: https://dev.murex.rocks/types/path.html

@orefalo
Copy link
Contributor Author

orefalo commented Aug 13, 2023

very nice site! ;-)
we did well.

Confirmed working. Thank you

@orefalo orefalo closed this as completed Aug 13, 2023
@lmorg
Copy link
Owner

lmorg commented Aug 13, 2023

very nice site! ;-)
we did well.

You did :) I'm going to push it live (so it's not just hooked up to the develop branch) as part of 5.0 release. Which will hopefully be later this month.

@lmorg lmorg removed a link to a pull request Aug 24, 2023
@lmorg lmorg mentioned this issue Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behavior
Projects
None yet
Development

No branches or pull requests

2 participants