Quando / porque você usa kill %%?

3

Eu vi pessoas usarem kill %% em vez de kill % . Tanto quanto eu posso dizer, ambos fazem o mesmo. Existe alguma diferença?

    
por eapen 24.01.2012 / 05:24

2 respostas

5

Citando a documentação:

There are a number of ways to refer to a job in the shell. The character % introduces a job specification (jobspec). Job number n may be referred to as %n. A job may also be referred to using a prefix of the name used to start it, or using a substring that appears in its command line. For example, %ce refers to a stopped ce job. If a prefix matches more than one job, bash reports an error. Using %?ce, on the other hand, refers to any job containing the string ce in its command line. If the substring matches more than one job, bash reports an error. The symbols %% and %+ refer to the shell's notion of the current job, which is the last job stopped while it was in the foreground or started in the background. The previous job may be referenced using %-. If there is only a single job, %+ and %- can both be used to refer to that job. In output pertaining to jobs (e.g., the output of the jobs command), the current job is always flagged with a +, and the previous job with a -. A single % (with no accompanying job specification) also refers to the current job.

(ênfase minha)

    
por 24.01.2012 / 09:30
-4

%% é usado em scripts do Windows para significar '%', já que% é um caractere especial. No entanto, os interpretadores de scripts do Windows também tentam ser espertos e, se um% é dado por si só com espaços em branco ao redor, então ele é tratado como% .. É irritante e bobo, mas lá vai você.

    
por 24.01.2012 / 05:50

Tags