2%> Return the contents of the ``.bash_profile`` file
3%> in the system
home folder as a scalar MATLAB
string.<br>
6%> If the file does not exist, create it.<br>
7%> If the file does not contain the Bash command to
8%> source the contents of the ``.bashrc`` file, then add
9%> it to the ``.bash_profile`` and
return its contents.<br>
12%> ``str`` : The output scalar MATLAB
string containing
13%> the contents of the ``.bash_profile``.<br>
18%> str = pm.sys.bash_profile.touch()
23%> \include{lineno} example/sys/bash_profile/
touch/main.m
25%> \include{lineno} example/sys/bash_profile/
touch/main.out.m
30%> \JoshuaOsborne, May 21 2024, 4:58 AM, University of Texas at Arlington<br>
31%> \FatemehBagheri, May 20 2024, 1:25 PM, NASA Goddard Space Flight Center (GSFC), Washington, D.C.<br>
32%> \AmirShahmoradi, May 16 2016, 9:03 AM, Oden Institute
for Computational Engineering and Sciences (ICES), UT Austin<br>
34 path = fullfile(pm.sys.path.
home(), ".bash_profile");
36 str =
string(fileread(path));
40 if ~contains(str, ".bashrc")
41 fid = fopen(path, 'a+');
42 fprintf(fid, '%s', [newline, '[ -f $HOME/.bashrc ] && . $HOME/.bashrc', newline]);
44 str =
string(fileread(path));
function home()
Return a MATLAB string containing the absolute path to the system home directory.
function touch()
Return the contents of the .bash_profile file in the system home folder as a scalar MATLAB string.