ParaMonte MATLAB 3.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
touch.m
Go to the documentation of this file.
1%> \brief
2%> Return the contents of the ``.bash_profile`` file
3%> in the system home folder as a scalar MATLAB string.<br>
4%>
5%> \details
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>
10%>
11%> \return
12%> ``str`` : The output scalar MATLAB string containing
13%> the contents of the ``.bash_profile``.<br>
14%>
15%> \interface{touch}
16%> \code{.m}
17%>
18%> str = pm.sys.bash_profile.touch()
19%>
20%> \endcode
21%>
22%> \example{touch}
23%> \include{lineno} example/sys/bash_profile/touch/main.m
24%> \output{touch}
25%> \include{lineno} example/sys/bash_profile/touch/main.out.m
26%>
27%> \final{touch}
28%>
29%> \author
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>
33function str = touch()
34 path = fullfile(pm.sys.path.home(), ".bash_profile");
35 if isfile(path)
36 str = string(fileread(path));
37 else
38 str = "";
39 end
40 if ~contains(str, ".bashrc")
41 fid = fopen(path, 'a+');
42 fprintf(fid, '%s', [newline, '[ -f $HOME/.bashrc ] && . $HOME/.bashrc', newline]);
43 fclose(fid);
44 str = string(fileread(path));
45 end
46end
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.