bryanmr / Steamy_Cats

A Steam Game Category Sorter Written in Bash
GNU General Public License v3.0
17 stars 1 forks source link

Issue with cut and username #9

Closed RiderExMachina closed 5 years ago

RiderExMachina commented 5 years ago

Tested on:

Problem: cut gives an error when running the script. Error: "cut: invalid field range". I'm unsure which line in particular is the issue, but manually editing Line 613 to OUR_CONFIG="$HOME/.steam/steam/userdata/$WHICHSTEAM/7/remote/sharedconfig.vdf seems to complete (at least with passing the user flag).

Tried:

Output:

bryanmr commented 5 years ago

WHICH_CONFIG=$(grep PersonaName ~/.steam/steam/userdata/*/config/localconfig.vdf | sed -n "$WHICHSTEAM"p | cut -d: -f1) let COUNT_SLASHES=$(grep -o "/" <<< "$WHICH_CONFIG" | wc -l)-1 OUR_CONFIG=$(cut -d/ -f1-$COUNT_SLASHES <<< "$WHICH_CONFIG")"/7/remote/sharedconfig.vdf"

That's the section that the error is coming from. The below should prevent it from happening.

https://github.com/bryanmr/Steamy_Cats/commit/65d8554fe673ec10b9f30eaca447e580658e2e66

RiderExMachina commented 5 years ago

8 has been resolved, however, now I get the following output (running on 65d8554):

Possible users to make Steam categories for:
1 : [LINUX] \<Username\>
Enter the number for the user you want to use. Answer: 1
We are using: [LINUX] \<Username\> :: 76561198058443459
cut: invalid field range
Try 'cut --help' for more information.
Our config file is: /7/remote/sharedconfig.vdf
cp: cannot stat '/7/remote/sharedconfig.vdf': No such file or directory
We can't find the config file.
This is important, so we are quitting.
bryanmr commented 5 years ago

Do you mind setting --debug --sequential and running again? The logic that finds your config file is failing, but I am not able to see how it is by looking at the code.

RiderExMachina commented 5 years ago
++ grep PersonaName /home/rider/.steam/steam/userdata/98177731/config/localconfig.vdf
++ sed -n 1p
++ cut -d: -f1
+ WHICH_CONFIG='                "PersonaName"           "[LINUX] <Username>"'
++ grep -o /
++ wc -l
+ let COUNT_SLASHES=0-1
++ cut -d/ -f1--1
cut: invalid field range
Try 'cut --help' for more information.
+ OUR_CONFIG=/7/remote/sharedconfig.vdf
+ echo 'Script Exited, files not cleaned up'
RiderExMachina commented 5 years ago

So it looks like COUNT_SLASHES isn't picking anything up

bryanmr commented 5 years ago

I changed the logic but I am worried about how that might be failing still.

https://github.com/bryanmr/Steamy_Cats/commit/fc7d0139beef7913365e01e53af497be4462b9f2

RiderExMachina commented 5 years ago

Nope:

+ OUR_CONFIG='          "PersonaName"           "[LINUX] <Username>"7/remote/sharedconfig.vdf'
+ echo 'Our config file is:             "PersonaName"           "[LINUX] <Username>"7/remote/sharedconfig.vdf'
Our config file is:             "PersonaName"           "[LINUX] <Username>"7/remote/sharedconfig.vdf
+ '[' '!' -e '          "PersonaName"           "[LINUX] <Username>"7/remote/sharedconfig.vdf' ']'
+ echo 'We can'\''t find the config file:               "PersonaName"           "[LINUX] \<Username>"7/remote/sharedconfig.vdf'
We can't find the config file:          "PersonaName"           "[LINUX] <Username>"7/remote/sharedconfig.vdf
+ echo 'This is important, so we are quitting.'
This is important, so we are quitting.
+ exit
+ echo 'Script Exited, files not cleaned up'
Script Exited, files not cleaned up
RiderExMachina commented 5 years ago

@bryanmr What's the intended operation for lines 621-623 in 65d8554?

bryanmr commented 5 years ago

Possible users to make Steam categories for: 1 : Username 2 : [LINUX] <Username> 3 : Username 4 : Username Enter the number for the user you want to use. Answer: 2 We are using: [LINUX] <Username> :: 000000 Our config file is: /home/bryan/.steam/steam/userdata/00000000/7/remote/sharedconfig.vdf Downloading your community profile, if public, and then getting full list of games you own Begin processing 45850 lines of configuration in /home/bryan/.steam/steam/userdata/0000000/7/remote/sharedconfig.vdf

I think I just figured it out, you only have one user, right?

https://github.com/bryanmr/Steamy_Cats/commit/d1d0d0e8e15413bef6a46d88ce2984b5020e9629

bryanmr commented 5 years ago

@bryanmr What's the intended operation for lines 621-623 in 65d8554?

I needed to add a -H to the grep on that line, so I always had the filename. The idea is for it to grab the lines that contain the names, print the specific line that has the one you select, and then only grab the filename.

I would then count the slashes since I wanted the strip off the last ones. I changed that to make it so now it just removes the string in the filename.

RiderExMachina commented 5 years ago

It doesn't error out, but it doesn't create new tags either. I think we can close this issue though, as the cut/username issue is sorted out now.