Skip to content

Commit c2a2127

Browse files
committed
Slides/notes on environment variables translated.
1 parent 8d172da commit c2a2127

File tree

2 files changed

+32
-32
lines changed

2 files changed

+32
-32
lines changed

file-api.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
\begin{itemize}
5757
\item This is a simplified view of the kernel tables that deal with files. It
5858
is modeled after a similar picture in [Bach]. Today it is more compliated but
59-
the main idea stays. See the next slide for how it may look present time
59+
the main idea stays. See the next slide for how it may look in present time
6060
systems.
6161
\item Each process on the system has its \emph{file descriptor table}.
6262
\item Slots in that table points to the \emph{system file table}. There is

intro.tex

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2013,38 +2013,38 @@
20132013
\pdfbookmark[1]{getenv, putenv, setenv}{envfuncs}
20142014

20152015
\begin{slide}
2016-
\sltitle{Manipulace s promìnnými prostøedí}
2016+
\sltitle{Manipulating the environment}
20172017
\begin{itemize}
2018-
\item je mo¾né pøímo mìnit promìnnou \texttt{environ}, SUSv3 to ale nedoporuèuje
2018+
\item it is possible to replace \texttt{environ} with a different array but in
2019+
general you should not do that
20192020
\item \texttt{char *\funnm{getenv} (const char *\emph{name});}
20202021
\begin{itemize}
2021-
\item vrátí hodnotu promìnné name
2022+
\item return value of \emph{name}
20222023
\end{itemize}
20232024
\item \texttt{int \funnm{putenv} (char *\emph{string});}
20242025
\begin{itemize}
2025-
\item vlo¾í string ve tvaru \texttt{\emph{jméno}=\emph{hodnota}} do
2026-
prostøedí (pøidá novou nebo modifikuje existující promìnnou)
2026+
\item inserts a string \texttt{\emph{name}=\emph{value}} into the
2027+
environment (adds a new or modifies an existing variable)
20272028
\end{itemize}
2028-
\item zmìny se pøená¹ejí do synovských procesù
2029-
\item zmìny v prostøedí syna samozøejmì prostøedí otce neovlivní
2030-
\item existují i funkce \funnm{setenv}() a \funnm{unsetenv}()
2029+
\item changes are propagated into children upon their creation
2030+
\item there are also functions \funnm{setenv}() a \funnm{unsetenv}()
20312031
\end{itemize}
20322032
\end{slide}
20332033

20342034
\begin{itemize}
2035-
\item u \texttt{putenv} se vlo¾ený øetìzec stane souèástí prostøedí (jeho
2036-
pozdìj¹í zmìna tak zmìní prostøedí) a nesmíte proto pou¾ívat retìzce v
2037-
automatických pro\-mìn\-ných, toto øe¹í \texttt{setenv}, který hodnotu promìnné
2038-
zkopíruje. Viz pøíklad \example{main/putenv.c}.
2039-
\item dùle¾ité je zapamatovat si, ¾e synovský proces zdìdí v okam¾iku svého
2040-
vzniku od rodièe v¹echny promìnné prostøedí, ale jakákoliv manipulace s nimi v
2041-
synovi je lokální a do otce se nepøená¹í. Ka¾dý proces má svou kopii
2042-
pro\-mìn\-ných, proto ani následná zmìna prostøedí otce nezmìní promìnné
2043-
ji¾ existujícího potomka.
2044-
\item dal¹í rozdíl mezi \texttt{putenv} a \texttt{setenv} je ten, ¾e v
2045-
\texttt{setenv} mohu definovat, zda existující promìnnou chci nebo nechci
2046-
pøepsat. \texttt{putenv} v¾dy pøepisuje.
2047-
\item
2035+
\item Read the description for \texttt{environ} in SUSv4 before assigning a new
2036+
value to the variable as there are important information there you should know.
2037+
\item When using \texttt{putenv}, the string will become part of the
2038+
environment, nothing is copied. You must not use automatic variables for such
2039+
strings. Use \texttt{setenv} to copy the value into the environment. Example:
2040+
\example{main/putenv.c}.
2041+
\item Changes in a child never changes its parent environment as those arrays
2042+
reside in separate address spaces.
2043+
\item Another difference between \texttt{putenv} and \texttt{setenv} is that in
2044+
\texttt{setenv} one can say whether an existing variable should be overwritten
2045+
or not. Function \texttt{putenv} always overwrites an existing variable.
2046+
\item Example:
2047+
20482048
\begin{verbatim}
20492049
int
20502050
main(void)
@@ -2053,17 +2053,17 @@
20532053
return (0);
20542054
}
20552055
$ ./a.out
2056-
jp
2056+
janp
20572057
\end{verbatim}
2058-
\item jeliko¾ promìnná \texttt{environ} je obyèejné pole ukazatelù na øetìzce,
2059-
není nebì¾né narazit na kód, který s tímto polem pracuje pøímo. Pozor v¹ak na
2060-
to, ¾e v takovém pøípadì pak ji¾ nesmíte pou¾ívat zde uvedené funkce, jinak se
2061-
mù¾ete dostat do problémù s jejich konkrétní implementací. A hlavnì, nový kód
2062-
takto nepi¹te, proto¾e norma SUSv3 pøímou práci s tímto polem nedoporuèuje.
2063-
\item pøíklad: \example{main/getenv.c}
2064-
\item pozor na to, ¾e je rozdíl mezi nastavením hodnoty promìnné na
2065-
prázdný string a odmazáním promìnné ze seznamu promìnných (pomocí
2066-
\texttt{unsetenv}).
2058+
2059+
\item As \texttt{environ} is just an array of pointers, you may find code that
2060+
directly manipulates it. However, any application that directly modifies the
2061+
pointers to which the environ variable points has undefined behavior according
2062+
to SUSv4, and that is possibly exacerbated if the functions introduced above are
2063+
used while doing that. Do not write code like that.
2064+
\item Example: \example{main/getenv.c}
2065+
\item Note that there is a difference between setting a variable to an empty
2066+
string and removing the variable from the environment via \texttt{unsetenv}.
20672067
\end{itemize}
20682068

20692069
%%%%%

0 commit comments

Comments
 (0)