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

Check in setup scripts if .bashrc already has a command in it #12

Open
ttchalakov opened this issue Oct 4, 2023 · 0 comments
Open

Check in setup scripts if .bashrc already has a command in it #12

ttchalakov opened this issue Oct 4, 2023 · 0 comments
Labels
code environment jetson or pc environment issues enhancement New feature or request

Comments

@ttchalakov
Copy link
Contributor

One very convenient improvement that could be made to the setup scripts for both the Jetson Nano and the PC development environments is to make them reusable. Currently, each setup script should only be run once on their target platform. While there are multiple things that would need to be done to make everything reusable in the scripts, the first thing is to deal with the following problem caused by adding code to a user's .bashrc:

echo "export CUDA_HOME=/usr/local/cuda" >> ~/.bashrc

This command appends export CUDA_HOME=/usr/local/cuda to the end end of the user's .bashrc. If the script is run multiple times then this line in the setup script will add another copy of the command to the end of the .bashrc script. Therefore we wish to check if the command already exists and if it does we should remove the old version and place append the new version.

To implement this feature, it would be best to create a bash function with parameters so that the code can be reused. An example implementation is outlined below:

INPUT: command, replace_flag, replace_pattern
IF replace_flag is true and replace_pattern is in .bashrc:
    replace line that contains replace_pattern with command
    exit function
ENDIF
    append command to end of .bashrc

sed is a command that allows you to perform basic text transformations using regular expressions. Google tutorials to learn about it or stack overflow will have code for your specific operation.

@ttchalakov ttchalakov added code environment jetson or pc environment issues enhancement New feature or request labels Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code environment jetson or pc environment issues enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant