Mercurial > hg
comparison mercurial/help/config.txt @ 16513:aa252059a98f stable
alias: fix shell alias documentation (issue3374)
Described behaviour was the one before shell alias argument handling was
reworked by f853873fc66d mid-2010.
author | Patrick Mezard <patrick@mezard.eu> |
---|---|
date | Tue, 24 Apr 2012 14:34:54 +0200 |
parents | 7416ce2c7887 |
children | 517b25608ad6 |
comparison
equal
deleted
inserted
replaced
16512:c58bdecdb800 | 16513:aa252059a98f |
---|---|
209 | 209 |
210 An alias can start with an exclamation point (``!``) to make it a | 210 An alias can start with an exclamation point (``!``) to make it a |
211 shell alias. A shell alias is executed with the shell and will let you | 211 shell alias. A shell alias is executed with the shell and will let you |
212 run arbitrary commands. As an example, :: | 212 run arbitrary commands. As an example, :: |
213 | 213 |
214 echo = !echo | 214 echo = !echo $@ |
215 | 215 |
216 will let you do ``hg echo foo`` to have ``foo`` printed in your | 216 will let you do ``hg echo foo`` to have ``foo`` printed in your |
217 terminal. A better example might be:: | 217 terminal. A better example might be:: |
218 | 218 |
219 purge = !$HG status --no-status --unknown -0 | xargs -0 rm | 219 purge = !$HG status --no-status --unknown -0 | xargs -0 rm |
220 | 220 |
221 which will make ``hg purge`` delete all unknown files in the | 221 which will make ``hg purge`` delete all unknown files in the |
222 repository in the same manner as the purge extension. | 222 repository in the same manner as the purge extension. |
223 | 223 |
224 Shell aliases are executed in an environment where ``$HG`` expand to | 224 Positional arguments like ``$1``, ``$2``, etc. in the alias definition |
225 expand to the command arguments. Unmatched arguments are | |
226 removed. ``$0`` expands to the alias name and ``$@`` expands to all | |
227 arguments separated by a space. These expansions happen before the | |
228 command is passed to the shell. | |
229 | |
230 Shell aliases are executed in an environment where ``$HG`` expands to | |
225 the path of the Mercurial that was used to execute the alias. This is | 231 the path of the Mercurial that was used to execute the alias. This is |
226 useful when you want to call further Mercurial commands in a shell | 232 useful when you want to call further Mercurial commands in a shell |
227 alias, as was done above for the purge alias. In addition, | 233 alias, as was done above for the purge alias. In addition, |
228 ``$HG_ARGS`` expand to the arguments given to Mercurial. In the ``hg | 234 ``$HG_ARGS`` expands to the arguments given to Mercurial. In the ``hg |
229 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``. | 235 echo foo`` call above, ``$HG_ARGS`` would expand to ``echo foo``. |
230 | 236 |
231 .. note:: Some global configuration options such as ``-R`` are | 237 .. note:: Some global configuration options such as ``-R`` are |
232 processed before shell aliases and will thus not be passed to | 238 processed before shell aliases and will thus not be passed to |
233 aliases. | 239 aliases. |