2b4d72322b163c41d4def4dc370044a186067ec0

Author
Marc Cornellà <marc.cornella@live.com>
Committer
GitHub <noreply@github.com>
Date

Message

debian: fix bad function definitions (#8129)

* Fix bad function definitions in Debian plugin

There appears to be a definition issue for some functions/aliases which
result in the following errors when sourcing .zshrc:

```
/home/username/.oh-my-zsh/plugins/debian/debian.plugin.zsh:75: defining function based on alias `abd'
/home/username/.oh-my-zsh/plugins/debian/debian.plugin.zsh:75: parse error near `()'
```

Fixes #7986

* Update syntax on the remaining functions

Diff

 1diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
 2index be4062ebff5568a3327f9c752026cf99174a0622..68c6df1aec688a5e60a22e729ff93fc03655bc6e 100644
 3--- a/plugins/debian/debian.plugin.zsh
 4+++ b/plugins/debian/debian.plugin.zsh
 5@@ -72,7 +72,7 @@ if [[ $use_sudo -eq 1 ]]; then
 6 # commands using su #########
 7 else
 8     alias aac="su -ls '$apt_pref autoclean' root"
 9-    abd() {
10+    function abd() {
11         cmd="su -lc '$apt_pref build-dep $@' root"
12         print "$cmd"
13         eval "$cmd"
14@@ -83,17 +83,17 @@ else
15     alias adu="su -lc '$apt_pref update && aptitude dist-upgrade' root"
16     alias afu="su -lc '$apt-file update'"
17     alias au="su -lc '$apt_pref $apt_upgr' root"
18-    ai() {
19+    function ai() {
20         cmd="su -lc 'aptitude -P install $@' root"
21         print "$cmd"
22         eval "$cmd"
23     }
24-    ap() {
25+    function ap() {
26         cmd="su -lc '$apt_pref -P purge $@' root"
27         print "$cmd"
28         eval "$cmd"
29     }
30-    ar() {
31+    function ar() {
32         cmd="su -lc '$apt_pref -P remove $@' root"
33         print "$cmd"
34         eval "$cmd"
35@@ -114,7 +114,7 @@ fi
36 # Registers a compdef for $1 that calls $apt_pref with the commands $2
37 # To do that it creates a new completion function called _apt_pref_$2
38 #
39-apt_pref_compdef() {
40+function apt_pref_compdef() {
41     local f fb
42     f="_apt_pref_${2}"
43 
44@@ -151,7 +151,7 @@ alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
45 
46 # Functions #################################################################
47 # create a simple script that can be used to 'duplicate' a system
48-apt-copy() {
49+function apt-copy() {
50     print '#!/bin/sh'"\n" > apt-copy.sh
51 
52     cmd='$apt_pref install'
53@@ -173,7 +173,7 @@ apt-copy() {
54 #   apt-history rollback
55 #   apt-history list
56 # Based On: https://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
57-apt-history () {
58+function apt-history() {
59   case "$1" in
60     install)
61       zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
62@@ -202,7 +202,7 @@ apt-history () {
63 }
64 
65 # Kernel-package building shortcut
66-kerndeb () {
67+function kerndeb() {
68     # temporarily unset MAKEFLAGS ( '-j3' will fail )
69     MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
70     print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
71@@ -216,10 +216,9 @@ kerndeb () {
72 }
73 
74 # List packages by size
75-function apt-list-packages {
76+function apt-list-packages() {
77     dpkg-query -W --showformat='${Installed-Size} ${Package} ${Status}\n' | \
78     grep -v deinstall | \
79     sort -n | \
80     awk '{print $1" "$2}'
81 }
82-